Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: are datagrid event handlers tied to viewstate ?


Message #1 by seba_i@y... on Mon, 17 Feb 2003 19:12:47
Hi,
It seems that if a DataGrid has EnableViewState="false" then the OnPageIndexChanged, OnSortCommand etc no longer fire (I'm using C# with codebehind) ?
However a search on the web shows a few VB examples where this seems ok (I can't find any for C#).
I would like EnableViewState="false" as it almost halves the page size and anyway the grid is rebound each round-trip. Does anyone know if this is/isn't possible, and why ? 

(snippet from aspx)
<asp:datagrid
  id="TaskGrid"
  runat="server"
  EnableViewState="false"
  OnPageIndexChanged="TGrid_PageIndexChanged"
  AllowPaging="True"
  PageSize="15" > etc... 

(snippet from codebehind)
protected void TGrid_PageIndexChanged(
  object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
  ViewState["SearchPageIndex"] = e.NewPageIndex;
  DoSearch();
} 

Thanks, Seb.

  Return to Index