Page_Load 中的数据库请求
在 Page_Load
中,我创建动态控件(带有复选框的表格)。复选框的数量取决于我从数据库中检索的一些信息。我不想在每次回发时都连接到数据库。保存所需变量的最佳方法是什么?也许我需要将它们存储在 HiddenField
中?
In Page_Load
I create dynamic controls (table with checkboxes). Number 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