GridView控件了ControlState-非常大,即使禁用视图状态和未使用的DataKeyNames [英] Gridview ControlState very large even when viewstate disabled and not using DataKeyNames
问题描述
我有一个asp:GridView的绑定到一个asp:ObjectDataSource控件。我已经禁用了GridView的ViewState中,并没有设置DataKeyNames属性。我有大约10绑定列和几个模板列。这些模板列未绑定到服务器控件,而是一个锚定标记或img标签。
I have an asp:Gridview bound to an asp:ObjectDataSource. I have disabled the ViewState on the GridView, and have not set the DataKeyNames property. I have about 10 BoundFields and a few TemplateFields. These TemplateFields are not bound to server controls but to an anchor tag or to an img tag.
然而,在运行时,当我打开页面跟踪我看到在GridView的了ControlState-显示只有14行数据的7和12K之间。 (渲染页面上查看源代码也给出了__VIEWSTATE隐藏字段中相同的长字符串)。我不明白为什么会这样,因为我有的EnableViewState =在GridView上造假,如上面说的,我不使用的DataKeyNames。所以,这是哪里的GridView了ControlState-来自哪里,是有摆脱它的方式是什么?
However, at runtime, when I switch on page tracing I see that the ControlState of the Gridview varies between 7 and 12K for displaying just 14 rows of data. (View source on the rendered page also gives a same long string in the __VIEWSTATE hidden field). I do not understand why this happens as I have enableViewState="false" on the gridview and, as said above, I am not using DataKeyNames. So, where is this Gridview ControlState coming from and is there a way to get rid of it?
在此先感谢,
蒂姆·
Thanks in advance, Tim
推荐答案
我认为它正常的,因为:
控制状态不能被禁止,控制状态是专为存储控件必须可用上回发的基本数据(如寻呼机控件的页号),以使控制甚至当视图状态已被禁用的功能
i think its normal because: control state cannot be disabled, Control state is designed for storing a control's essential data (such as a pager control's page number) that must be available on postback to enable the control to function even when view state has been disabled
请注意:默认情况下,ASP.NET页面框架专卖店在在它存储视图状态相同的隐藏元素的页面控制状态。即使视图状态被禁用微软称
这意味着你确实看到了ControlState-在_ViewState字段中的数据这是确定
因为作为微软表示,控制了ControlState-存储在ViewState中即使禁用ViewState的
that mean you actually saw the data of ControlState in _ViewState field which is ok because as microsoft said the ControlState of the control stored in viewstate even if you disable ViewState
这篇关于GridView控件了ControlState-非常大,即使禁用视图状态和未使用的DataKeyNames的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!