Is there anyway to have the webdatagrid keep it's page and/or sort when using the back button of the browser? If you sort or page thru the grid, select a hyperlink and then hit back, the grid goes back to the original state/view from the binding of the datasource.
Hello jaboof,
By default WebDataGrid does not keep sorting/paging on cross paging.
One way to achieve this is manually saving Sorting and Paging information in Session variables.
For example:
Session["PageIndex"] = WebDataGrid1.Behaviors.Paging.PageIndex;
Session["SortedColumnKey"] = WebDataGrid1.Behaviors.Sorting.SortedColumns[0].ColumnKey;
Session["SortedColumnDirection"] = WebDataGrid1.Behaviors.Sorting.SortedColumns[0].SortDirection;
Let me know if you need further assistance.
Hi,
Excuse me i'm trying to save the sorting and paging of my webdatagrid.
I have a event that i call when the sorting is trigered to save the information like you advise it.
But i have a problem. i don't see how i can apply this session variables to my webdatagrid. I was just able to use the columnkey on my grid. But i don't know how to use the paging and colum direction variables.
Presently I'm doing this in my page load :
if (Session["mySort"] != null) { WebDataGrid1.Behaviors.Sorting.SortedColumns.Add(Session["SortedColumnKey"].ToString(), Infragistics.Web.UI.SortDirection.Ascending); }
Finaly i have found a solution for the session variable page index i do this :
if (Session["mySort"] != null) { WebDataGrid1.Behaviors.Sorting.SortedColumns.Add(Session["SortedColumnKey"].ToString(), Infragistics.Web.UI.SortDirection.Ascending); WebDataGrid1.Behaviors.Paging.PageIndex= Convert.ToInt32(Session["PageIndex"]); }
But i still don't know how to use the Session["SortedColumnDirection"] variable.
i don't know if it's the best way but it works. If it can help someone.
if (Session["mySort_Ech"] != null) { Infragistics.Web.UI.SortDirection Direction = new Infragistics.Web.UI.SortDirection(); if (Session["SortedColumnDirection_Ech"].ToString() == "Ascending") { Direction = Infragistics.Web.UI.SortDirection.Ascending; } else if (Session["SortedColumnDirection_Ech"].ToString() == "Descending") { Direction = Infragistics.Web.UI.SortDirection.Descending; } WebDataGrid2.Behaviors.Sorting.SortedColumns.Add(Session["SortedColumnKey_Ech"].ToString(),Direction); WebDataGrid2.Behaviors.Paging.PageIndex = Convert.ToInt32(Session["PageIndex_Ech"]); }