disabling viewstate on datagrid

S

sonic

Hi,
I am experimenting with different viewstate management ideas for large
datagrids, and found a microsoft suggestion to turn it off, and only
store relevant information by manually accessing viewstate. as per some
helpful suggestins in MSDN "Common DataGrid Mistakes"
http://msdn.microsoft.com/library/d...dnaspp/html/aspnet-commondatagridmistakes.asp

they suggest disabling datagrid viewstate and adding selective
information to it i.e. ViewState["editindex"] = this.EditItemIndex etc.

the problem i encountered is, when i set EnableViewState=false, nothing
gets saved there, even though i explicitly save / load viewstate
variables.

Any advice in having it disabled but still using it ?
 
E

Eliyahu Goldin

Where do you specify EnableViewState=false? For the whole page in the <%@
Page...> directive? You should do it only for the grid and other components
you want the ViewState to be off.

Eliyahu
 
G

Guest

I have the same problem. When I disable datagrid viewstate, it skips the
datagrid1__SelectedIndexChanged routine entirely.

George

Eliyahu Goldin said:
Where do you specify EnableViewState=false? For the whole page in the <%@
Page...> directive? You should do it only for the grid and other components
you want the ViewState to be off.

Eliyahu

sonic said:
Hi,
I am experimenting with different viewstate management ideas for large
datagrids, and found a microsoft suggestion to turn it off, and only
store relevant information by manually accessing viewstate. as per some
helpful suggestins in MSDN "Common DataGrid Mistakes"
http://msdn.microsoft.com/library/d...dnaspp/html/aspnet-commondatagridmistakes.asp

they suggest disabling datagrid viewstate and adding selective
information to it i.e. ViewState["editindex"] = this.EditItemIndex etc.

the problem i encountered is, when i set EnableViewState=false, nothing
gets saved there, even though i explicitly save / load viewstate
variables.

Any advice in having it disabled but still using it ?
 
V

vMike

George said:
I have the same problem. When I disable datagrid viewstate, it skips the
datagrid1__SelectedIndexChanged routine entirely.

George

Eliyahu Goldin said:
Where do you specify EnableViewState=false? For the whole page in the <%@
Page...> directive? You should do it only for the grid and other
components
you want the ViewState to be off.

Eliyahu

sonic said:
Hi,
I am experimenting with different viewstate management ideas for large
datagrids, and found a microsoft suggestion to turn it off, and only
store relevant information by manually accessing viewstate. as per some
helpful suggestins in MSDN "Common DataGrid Mistakes"
http://msdn.microsoft.com/library/d...dnaspp/html/aspnet-commondatagridmistakes.asp

they suggest disabling datagrid viewstate and adding selective
information to it i.e. ViewState["editindex"] = this.EditItemIndex etc.

the problem i encountered is, when i set EnableViewState=false, nothing
gets saved there, even though i explicitly save / load viewstate
variables.

Any advice in having it disabled but still using it ?
Try reloading the datagrid on page_init or page_load even during postback.
Mike
 
G

Guest

Thanks vMike. Probably that's the only way to databind the datagrid
everytime. But how do I know what is the new page selection, or the sort
column, if I databind in the Page_Load?

George

vMike said:
George said:
I have the same problem. When I disable datagrid viewstate, it skips the
datagrid1__SelectedIndexChanged routine entirely.

George

Eliyahu Goldin said:
Where do you specify EnableViewState=false? For the whole page in the <%@
Page...> directive? You should do it only for the grid and other
components
you want the ViewState to be off.

Eliyahu

Hi,
I am experimenting with different viewstate management ideas for large
datagrids, and found a microsoft suggestion to turn it off, and only
store relevant information by manually accessing viewstate. as per some
helpful suggestins in MSDN "Common DataGrid Mistakes"

http://msdn.microsoft.com/library/d...dnaspp/html/aspnet-commondatagridmistakes.asp

they suggest disabling datagrid viewstate and adding selective
information to it i.e. ViewState["editindex"] = this.EditItemIndex etc.

the problem i encountered is, when i set EnableViewState=false, nothing
gets saved there, even though i explicitly save / load viewstate
variables.

Any advice in having it disabled but still using it ?
Try reloading the datagrid on page_init or page_load even during postback.
Mike
 
V

vMike

George said:
Thanks vMike. Probably that's the only way to databind the datagrid
everytime. But how do I know what is the new page selection, or the sort
column, if I databind in the Page_Load?

George

vMike said:
George said:
I have the same problem. When I disable datagrid viewstate, it skips the
datagrid1__SelectedIndexChanged routine entirely.

George

:

Where do you specify EnableViewState=false? For the whole page in the <%@
Page...> directive? You should do it only for the grid and other
components
you want the ViewState to be off.

Eliyahu

Hi,
I am experimenting with different viewstate management ideas for large
datagrids, and found a microsoft suggestion to turn it off, and only
store relevant information by manually accessing viewstate. as per some
helpful suggestins in MSDN "Common DataGrid Mistakes"

http://msdn.microsoft.com/library/d...dnaspp/html/aspnet-commondatagridmistakes.asp

they suggest disabling datagrid viewstate and adding selective
information to it i.e. ViewState["editindex"] = this.EditItemIndex etc.

the problem i encountered is, when i set EnableViewState=false, nothing
gets saved there, even though i explicitly save / load viewstate
variables.

Any advice in having it disabled but still using it ?
Try reloading the datagrid on page_init or page_load even during postback.
Mike
In general, if the datagrid is user specific you may need to maintain
viewstate or it will go back to its original state. The only other choice is
to maintain some hidden fields or other smaller items in viewstate that will
enable you to recreate the datagrid in the state that the user had at the
time of postback. IMHO viewstate is used to maintain the state of controls
that are specific to one user as opposed to any user.
 

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,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top