What do you do when you can't use ViewState?

后端 未结 7 1798
长发绾君心
长发绾君心 2021-02-09 06:43

I have a rather complex page that dynamically builds user controls inside of a repeater. This repeater must be bound during the Init page event before ViewState is

7条回答
  •  太阳男子
    2021-02-09 07:16

    I have always recreated my dynamic controls in the LoadViewState event. You can store the number of controls needed to be created in the viewstate and then dynamically create that many of them using the LoadControl method inside the LoadViewState event. In this event you have access to the ViewState but it has not been restored to the controls on the page yet.

提交回复
热议问题