viewState & datagrid

D

Dave

Hi,
I'm confused by the role that the viewState plays in maintaining the values
in a datagrid.

I have a datagrid that is loaded with the appropriate data. A new page is
choosen, firing the PageIndexChanged event. Does the viewState maintain the
values in the datagrid? (To me, it appears that the viewState does NOT
maintain the values in the dataGrid.)

If the viewState doesn't maintain the datagrid's values, what does it do? To
get the new page to be displayed, I have to re-populate the datagrid.

Yet, it looks like when I have the datagrid sorted on a specific column, and
the user chooses a new page, the sort criteria is maintained. Do I have
that correct?

So what does enabling the viewState on the datagrid accomplish?

TIA,
Dave
 
D

Datagrid Girl [MVP]

Hi Dave,
Basically, the ViewState keeps the SortExpression and the EditItemIndex for
you. If you store those two items manually (can still use ViewState), I
usually recommend that people turn off ViewState for the Datagrid to cut
down on the size of the page. Technically the ViewState DOES contain the
data for all the rows, but it doesn't seem to appear in any usable fashion,
at least not that I've found.

Datagrid Girl
http://www.datagridgirl.com
http://weblogs.asp.net/datagridgirl
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top