I'm using a DataPager to add pagination to my ListView. On PageLoad, a search is performed using a query string, and it then adds the results to DataSet that I use to populate the ListView.
The DataPager itself is very basic, all I use is this:
<asp:DataPager ID="ListViewPager" PagedControlID="listViewResults" PageSize="10" runat="server" QueryStringField="page">
<Fields>
<asp:NextPreviousPagerField ButtonType="Link" PreviousPageText="Previous" ShowFirstPageButton="false" ShowNextPageButton="false" ShowPreviousPageButton="true" />
<asp:NumericPagerField ButtonType="Link" />
<asp:NextPreviousPagerField ButtonType="Link" NextPageText="Next" ShowLastPageButton="false" ShowNextPageButton="true" ShowPreviousPageButton="false" />
</Fields>
</asp:DataPager>
However, when switching between pages, the results load extremely slowly. Seeing that the search itself is performed on PageLoad (if querystring != null), does it perform that search all over again whenever I go to a new page? If so, is there a better way to handle this so the pages load faster?
Page_Loadruns on every postback, so you should useif(!PostBack && querystring != null). Also, paginate your data directly in the DB, not in the code - it's incomparably faster.