I have created all gridview column dynamically and column also exists checkbox. Issue with gridview is its not preserving dynamic created column value. For example if i have selected few row through checkbox column and clicked on button to get all selected row id. As page post back the grid becomes empty with no data value.
我已动态创建所有gridview列,列也存在复选框。 gridview的问题是它不保留动态创建的列值。例如,如果我选择了几个行到复选框列并单击按钮以获取所有选定的行ID。当页面回发时,网格变为空,没有数据值。
Any help will be highly appreciated.
任何帮助将受到高度赞赏。
Thanks, Alvin
1 个解决方案
#1
This is probably caused by when you're creating the dynamic column.
这可能是由于您创建动态列时造成的。
If the column is created in the Page_Load event, or later in the page event process, then ViewState will not be able to populate your columns on a PostBack.
如果在Page_Load事件中创建列,或者在页面事件过程中稍后创建列,则ViewState将无法在PostBack上填充列。
If possible, try creating your dynamic columns in the Page_Init event. This will allow ViewState to load the columns properly.
如果可能,请尝试在Page_Init事件中创建动态列。这将允许ViewState正确加载列。
#1
This is probably caused by when you're creating the dynamic column.
这可能是由于您创建动态列时造成的。
If the column is created in the Page_Load event, or later in the page event process, then ViewState will not be able to populate your columns on a PostBack.
如果在Page_Load事件中创建列,或者在页面事件过程中稍后创建列,则ViewState将无法在PostBack上填充列。
If possible, try creating your dynamic columns in the Page_Init event. This will allow ViewState to load the columns properly.
如果可能,请尝试在Page_Init事件中创建动态列。这将允许ViewState正确加载列。