minimizing viewstate

J

Justin

I have aspx pages with 10 checkboxlist controls. total individual checkbox
(the sum of individual checbox in those 10 checkboxlists) on the page is
about 1710. You can imagine how large the viewstate is. Is there anyway I
can shrink the viewstate and at the same time get the values of each
checkbox after postback?

Thanks
 
C

Chris Chilvers

I have aspx pages with 10 checkboxlist controls. total individual checkbox
(the sum of individual checbox in those 10 checkboxlists) on the page is
about 1710. You can imagine how large the viewstate is. Is there anyway I
can shrink the viewstate and at the same time get the values of each
checkbox after postback?

Thanks

On this same point is there anyway to disable saving the data of
controls that hold large amounts of data such as dropdownlists and
datagird but still allow them to store all the smaller values in
viewstate for things like which item index/row index was last
selected?

This would have the basic contract that you would be responsible for
repopulating the data during the init phase so that it is ready for
LoadSavedState.
 
C

CMM

You should ask this question in the aspnet groups, not here.... but
anyhow....

Not sure about the Checkboxlist.... but disabling ViewState does not prevent
you from getting a postback value from any control. In Page_Load
"reconstruct" your checkboxes.... the events fire next, and you will be able
to retrieve the Postbox "value."

I haven't experimented with Checkboxlist.... I know things with ViewState
can get a bit confusing.
 
C

CMM

Also

Yeah. Disable ViewState for the control, and add your own values to
ViewState manually (ViewState("myvalue") = Somecontrol.SomeValue) and reset
the property in question of the control on Postbacks in Page_Load.

In fact, try completely disabling the ViewState for the Checkboxlist control
and see if you lose anything. I'll be you don't. If you're adding items
manually in Page_Load rather than in the designer simply remove the If
Me.IsPostBack and "reconstruct" the items on every postback. This works
beautifully and everything works!

Note you do not have to "reconstruct" the items in your Checkboxlist in
Page_Load if you define the items in the ASP markup (in the designer). Only
if you create the Checkboxlist.Items manually in code (in the Page_Load
event for instance).

Basically, ViewState allows you to make changes to your controls in the
Code-Behind and have those changes saved on subsequent postbacks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top