Is it possible to implement paging in a Gridview using a cached SqlDataSource? I want to run the query once, the results will be stored in the cache, and then I can just go through the Gridview pages and load the cached result when the pages change, without restarting the query? I know that itβs more efficient to just capture only the records that I need for the current page, but since I will be able to export to Excel on the page, I want everything to be captured at a time.
<asp:GridView ID="Results" runat="server" AutoGenerateColumns="False"
AllowSorting="true" DataSourceID="SqlDataSource1" OnSorting="Submit_Query" CellPadding="5" Class="highlightable"
OnRowDataBound="Results_RowDataBound"
OnPageIndexChanging="GridView_PageIndexChanging" AllowPaging="true" PageSize="100" EmptyDataText="No Data Found">
</asp:GridView>
SqlDataSource:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" EnableCaching="true" ></asp:SqlDataSource>
Function performed when the page is changed
protected void GridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
Results.PageIndex = e.NewPageIndex;
}
Is it possible?
source
share