[thelist] (ASP.NET) Datagrid persistance, perhaps?

Tab Alleman talleman at Lumpsum.com
Tue Sep 27 14:49:59 CDT 2005


I've got a datagrid, for which I want to enable automatic paging and sorting.

The problems are that:

1) when I click one of the column headers (to sort by the column), I get "System.Data.DataException: DataTable must be set prior to using DataView."

2) When I click the "next" link to get the next page of data results, I get "System.Web.HttpException: Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount."

3) When I change the PageSize of the datagrid, to show more results on the page, I get "DataGrid with id 'dgSearchResults' could not automatically generate any columns from the selected data source."


It's as though everytime I do a post-back the DataView that is the source of the DataGrid isn't persisting.

My datagrid does have EnableViewState=true.

On postback, I DO re-bind the DataGrid to the DataView with:
        dgSearchResults.DataSource = dvResults   'dvResults is the DataView, dgSearchResults is the DataGrid.
        dgSearchResults.DataBind()

My understanding from what I've read is that my DataView should therefore persist through a post-back without my having to requery the database to get the data again.   Am I leaving something out here, can ya tell?   



More information about the thelist mailing list