开发者

Database request in Page_Load

开发者 https://www.devze.com 2023-02-28 03:37 出处:网络
In Page_Load I create dynamic controls (table with checkboxes). N开发者_如何转开发umber of checkboxes depends on some information that I retrieve from my database. I don\'t want to connect to the data

In Page_Load I create dynamic controls (table with checkboxes). N开发者_如何转开发umber of checkboxes depends on some information that I retrieve from my database. I don't want to connect to the database on every postback. What is the best way to save needed variables? Maybe I need to store them in HiddenField?


store them inside the viewstate, which is more or less storing in a hiddenField (as the viewstate itself gets persisted to a hiddenfield)

viewstate @ msdn


It is recommended to get your variables values from database in this case. However, if you choose not to follow the recommendation, you still can store these values as session state variables if it is ok in your system...

If you run out of options you can consider using ViewState variables to store your variables.


Read about State Variables

0

精彩评论

暂无评论...
验证码 换一张
取 消