Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 860
  • Last Modified:

SortCommand, PageIndexChanged, ItemCommand events of datagrid

Is it necessary to set the EnableViewState of datagrid as true to implement ItemCommand, SortCommand and PageIndexChanged event of datagrid. If not then how can i get these events working even after setting the EnableViewState property of datagrid as false. Actually in my grid, if i set EnableViewState as true then events are working fine but not otherwise. Could anybody give any suggestions regarding this???

Thanks & Regards
Sachit.
0
sachitjain
Asked:
sachitjain
1 Solution
 
tusharashahCommented:
ViewState holds current state of Web Controls. If you set it to false ViewState will have no information regarding the DataGrid displayed. ex. the datagrid would not be able to maintain current-page-index by itself and that may be reason why the PageIndexChanged event handler did not fire.

So, if you are taking help of inbuilt paging, sorting or you want some datagrid inforamtin in PostBack you'll need EnableViewState=True for Datagrid..

You can read some more about this here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspnet-pageablesortable.asp

-tushar
0
 
raterusCommented:
Put the DataGrid on a diet if you are concerned about the viewstate!
http://authors.aspalliance.com/JimRoss/Articles/DatagridDiet.aspx
0
 
sachitjainAuthor Commented:
Thanks raterus

The reference given by u is great.

Regards
Sachit.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now