Dynamic Controls and Postback

拜拜、爱过 提交于 2019-11-29 13:04:49

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

Make sure that the controls get the same ID each time (for ex. by specifying an ID explicitly) and you should add the dynamic controls on Page.Init so they can participate in the page's life-cycle.

There's an article on 4guysfromrolla.com, Dynamic Web Controls, Postbacks, and View State

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!