Home Asp.net DataPager PagerTemplate

Tips and tricks

Site statistics

Members : 19
Content : 104
Content View Hits : 18546

Who's Online

We have 12 guests online
DataPager PagerTemplate PDF Print E-mail
User Rating: / 0
PoorBest 
Articles - Asp.net
Written by Dot4Pro   
Thursday, 03 December 2009 16:31

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="&lt; Prev 10" NextPageText="Next 10 &gt;"
                ButtonCount="5" />
            <asp:NextPreviousPagerField ShowPreviousPageButton="false" ShowLastPageButton="true" ShowNextPageButton="True" />
        </Fields>
    </asp:DataPager>

Last Updated on Thursday, 17 December 2009 16:29
 

Add comment


Security code
Refresh

feed-image Feed Entries