BumbleBee
BumbleBee

Reputation: 10779

Enabling ViewStateMode doesn't work for the child controls of a child control

I am working on .net 4.0 application. I am trying to load a bunch of custom controls that has a "gridview" control along with several text boxes and dropdowns. As the viewstate is really slowing down the system in order to improve the performance I Disabled the ViewStateMode of the parent control (i.e User control) and Enabled the ViewStateMode for dropdowns. But the problem I have is the dropdowns inside the gridview and panel thrw an error even though their ViewStateMode is Enabled. If I Enable the ViewStateMode of gridView or Panel it works fine but that's increasing the size of Viewstate. Can somebody please make me understand why it is happening and what is the solution for this?

Thanks BB

Upvotes: 0

Views: 375

Answers (1)

user240141
user240141

Reputation:

If you are getting tons of viewstate.Then I would suggest you two ways that worked for me too

  1. Compress Viewstate - http://www.codeproject.com/KB/viewstate/ViewStateCompression.aspx, http://www.hanselman.com/blog/ZippingCompressingViewStateInASPNET.aspx

  2. Trace the layout of the rendering area in html, using div , ul, li wahtever. Now instead of placing grids and other server controls, get the datasource(datatable or dataset), itereate through the items and make the html in the codebehind and write the final html tag on page using a literal. using html controls you can get rid of the view state issues. Also on that html tag you can apply jquery to make it better too.

Upvotes: 1

Related Questions