Click here to Skip to main content
Click here to Skip to main content

GridView Pager Template

By , 10 May 2013
 

I recently created a dynamic data project and needed to change its layout, most things went well until I came to changing the list page. This consisted of a Gridview and standard pager template.  I had already started using bootstrap (for ease of use) so wanted to change the table to use bootstrap table classes with its standard pager. After much searching I managed to get the table outputting correctly using CSS Friendly adapters. However, the pager was a bit lacking.

I had already developed a paging control for a different project and it looked like a fairly simple modification to get it to use the grid view.

The pagers itself is a scrolling window pager with:

  • Optional ‘First/Last’ and ‘Previous/Next’ links with easily changable text
  • Changeable ’Pager links to show’ setting
  • Easily modifiable html output

Simply add the following class into your project

GridPager

Gridview pager template class

Reference it in your grid view, this is how my grid view looks.

<asp:GridView ID="GridView1"
    runat="server"
    DataSourceID="GridDataSource"
    AllowPaging="True"
    AllowSorting="True"
    CssClass="table table-striped"
    AutoGenerateEditButton="True"
    AutoGenerateDeleteButton="True"
    PageSize="5" >
    <PagerTemplate>
        <asp:GridPager ID="GridViewPager1" runat="server"
            ShowFirstAndLast="True"
            ShowNextAndPrevious="True"
            PageLinksToShow="10"
            NextText="›"
            PreviousText="‹"
            FirstText="«"
            LastText="»"/>
    </PagerTemplate>
    <EmptyDataTemplate>
        There are currently no items in this table.
    </EmptyDataTemplate>
</asp:GridView>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Antony Gayter
United Kingdom United Kingdom
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130513.1 | Last Updated 10 May 2013
Article Copyright 2013 by Antony Gayter
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid