Dynamic Controls and Postback

前端 未结 2 1302
天命终不由人
天命终不由人 2020-12-20 08:27

I have a Panel. Now in that panel, i\'m adding controls. It is getting added and displayed.The problem is when the page is posted back.I know the controls have to be binded

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-20 09:02

    I have done this before by storing the data from the controls in session.

    Every time you dynamically add a control, store the current data entered into the controls in session or viewstate for example, and then rebind on postback. Not the most elegant solution but it worked. I take it this is a webforms question?

    1. Add dynamic control click
    2. Save current form data
    3. On page_load load the data from viewstate into the controls

提交回复
热议问题