DataPager PagerTemplate

Datapager example

DataPager is a independent paging control in asp.net 3.5 which can be used with any databound controls which implments  IPageableContainer interface.

DataPager properties:

PageSize : Size of the rows in a sinlge page to be displayed.

QueryStringField: Query string name which is suffied on the url to control paging

PagedControlId: Id of the databound control to which paging has to be done.

Fields template controls how the paging navigation elements like Next,Previous, Numeric Navigator are displayed.

<asp:NextPreviousPagerField /> show Next,Previous,First,Last navigation elements

<asp:NextPreviousPagerField /> creates Numeric navigation links

There is another field type called TemplatePagerFIeld which can be used to display paging elements in your own way. In the following sample TemplatePagerField is used to display current page number.

DataPager example code with TemplatePagerField

<asp:DataPager ID="DataPager1" PageSize="10" runat="server" QueryStringField="user"

PagedControlID="GridViewExt1">

<Fields>

<asp:TemplatePagerField>

<PagerTemplate>

Page

<%# Container.TotalRowCount>0 ? (Container.StartRowIndex / Container.PageSize) + 1 : 0 %>

of

<%# Math.Ceiling ((double)Container.TotalRowCount / Container.PageSize) %>

(<%# Container.TotalRowCount%>

records)

</PagerTemplate>

</asp:TemplatePagerField>

<asp:NextPreviousPagerField ShowFirstPageButton="true" ShowNextPageButton="false"

ShowPreviousPageButton="True" />

<asp:NumericPagerField PreviousPageText="Prev 10" NextPageText="Next 10 "

ButtonCount="5" />

<asp:NextPreviousPagerField ShowPreviousPageButton="false" ShowLastPageButton="true" ShowNextPageButton="True" />

</Fields>

</asp:DataPager>
, ,

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Share to Facebook Share to Twitter Stumble It Share on Tumblr Digg More...