I have a datagrid that has 3 pages of data. I have allowed paging and sorting. They both work ok except with one issue with the sorting.
The sorting is applied correctly when I click a column header but then if I then go and click on the page index the sorting is reset.
Any ideas on how to preseve the sorting while swiching pages on a datagrid?
protected void dgCompInfo_OnPageIndexChanging(object sender, DataGridPageChangedEventArgs e)
{
dgCompInfo.CurrentPageIndex = e.NewPageIndex;
dgCompInfo.DataSource = GetDataTableForGrid();
dgCompInfo.DataBind();
}
What I ended up doing is adding the DataTable used for the grid to the Session and used that on the binding of the OnPagingIndexChanging.
Works like a champ now!!