I'm using a standard GridView with a LinqDataSource. The user can sort and page through the grid using the stock standard stuff. Searching criteria (WhereParameters) can also be used to filter the results. This works great, but the state is obviously lost whenever navigating away from the page.
So a generic mechanism of capturing the Sort and Pagining state as well as the WhereParameter values would be great. One would then be able to add these values to a Session and restore them whenever the user navigates back to the page.
Any help would be much appreciated.
My code as follows:
<asp:GridView ID="dataGridView" runat="server"
AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False"
CssClass="GridView"
DataSourceID="linqDataSource"
PageSize="20">
<Columns>
<asp:BoundField
HeaderText="Name"
DataField="Name"
SortExpression="Name" />
<asp:TemplateField
HeaderText="Province"
SortExpression="Province.Name">
<ItemTemplate>
<%# Eval("Province.Name")%></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:LinqDataSource ID="linqDataSource" runat="server"
ContextTypeName="DataContext"
TableName="Schools"
EnableUpdate="True"
EnableDelete="True"
Where="Name.Contains(@Name) && (ProvinceID == @ProvinceID)">
<WhereParameters>
<asp:ControlParameter
Name="Name"
DefaultValue=""
ControlID="tbName"
Type="String"
ConvertEmptyStringToNull="False" />
<asp:ControlParameter
Name="ProvinceID"
DefaultValue=""
ControlID="ddlProvince"
Type="Int32" />
</WhereParameters>
</asp:LinqDataSource>