Gridview ControlState very large even when viewstate disabled and not using DataKeyNames

纵然是瞬间 提交于 2019-12-01 20:27:38

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

note: By default, the ASP.NET page framework stores control state in the page in the same hidden element in which it stores view state. Even if view state is disabled microsoft said

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

If you're disabling viewstate, not using any postback controls within the gridview, and not doing paging/sorting, then you're probably better off using a repeater. Repeaters don't have to be placed inside a tag. So, the control state won't be an issue.

If you're using .net 3.5 you could also investigate using the ListView, which to me seems like a repeater / gridview hybrid.

This article says that control state is actually stored in the __VIEWSTATE in a HybridDictionary.

Also, these articles say that even though you can set EnableViewState=false, you can never turn off ControlState (which is the point - so clients can't break your application):

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!