DataGrid Sorting Problem using a DataSet from ViewState
-
I've got a page with two panels. The first panel contains the search parameters (textboxes and drop downs). The second panel shows the results of the search. On the result page, i allow paging and sorting. Everything works great if i rebuild the dataset each time i change pages or change the sort. But when I cache the dataset in ViewState and try to change pages or the sort, it just takes my back to the parameter page automatically. Nothing else happens. Here's my code for the Sort:
ViewState.Add("str_sortOrder", e.SortExpression); DataView dvwResults = new DataView(); dvwResults = dst_searchResults.Tables[0].DefaultView[0].DataView; dvwResults.Sort = ViewState["str_sortOrder"].ToString(); this.dgr_searchResults.DataSource = dvwResults; this.dgr_searchResults.DataKeyField = "aut_companyID"; this.dgr_searchResults.DataBind();
All help is appreciated. Brian -
I've got a page with two panels. The first panel contains the search parameters (textboxes and drop downs). The second panel shows the results of the search. On the result page, i allow paging and sorting. Everything works great if i rebuild the dataset each time i change pages or change the sort. But when I cache the dataset in ViewState and try to change pages or the sort, it just takes my back to the parameter page automatically. Nothing else happens. Here's my code for the Sort:
ViewState.Add("str_sortOrder", e.SortExpression); DataView dvwResults = new DataView(); dvwResults = dst_searchResults.Tables[0].DefaultView[0].DataView; dvwResults.Sort = ViewState["str_sortOrder"].ToString(); this.dgr_searchResults.DataSource = dvwResults; this.dgr_searchResults.DataKeyField = "aut_companyID"; this.dgr_searchResults.DataBind();
All help is appreciated. BrianPlease redirect your question to the appropriate forum, the ASP.NET[^] forum. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]