我正在尝试优化ASP.NET 4.0应用程序的视图状态。 由于gridview正在向viewstae添加大量数量,因此我禁用了viewstateMode。 当我禁用viewstate时,这些是我遇到的以下问题。
1) On a postback the Gridview is blank.
2) In order to overcome the above problem I tried to bind the data in OnPreRender() then I ran into another problem : The Delete (Rowdelte) and Rowcommand doesn't fire.
在回发中将数据绑定到datagrind的最佳位置是什么,这样它就不会影响其余的事件。
答案 0 :(得分:0)
确保您禁用了viewstate,因此请确保gridview的datakeynames属性。 Gridview可以通过删除任何if!ispostback来回发数据绑定。
当您在预渲染中进行数据绑定时(您可以绑定的最后一个点),您正在跳过数据绑定控件'在预渲染之前发生的事件。
另外,这个链接, http://msdn.microsoft.com/en-us/library/ms178472(v=vs.100).aspx,解释生命周期。 您可以在此处查看viewstate,http://msdn.microsoft.com/en-us/library/bb386448.aspx