Click here to Skip to main content
Licence CPOL
First Posted 10 Jun 2009
Views 40,882
Downloads 2,769
Bookmarked 39 times

Client Side Gridview Pagination using JQuery

By sagnik mukherjee | 10 Jun 2009
Client Side Gridview Paging using Jquery

1

2

3
3 votes, 50.0%
4
3 votes, 50.0%
5
4.43/5 - 6 votes
μ 4.43, σa 0.96 [?]
2.JPG

Introduction 

Here, I would like to show how to use Client Side Gridview Pagination using Jquery Table Pagination Plugin by using Ryan Zielke.  

Using the Code

First create a folder called "images". Then paste all the image files into that folder.

1.JPG

Next, add the reference of Jquery and Plugin JavaScript file in the ASPX Page.   

<script src="jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="jquery.tablePagination.0.1.js" type="text/javascript"></script>

Then add the CSS below. Here Width value of #testTable must be the same as the Width of your Gridview control.

#testTable { 
            width : 300px;
            margin-left: auto; 
            margin-right: auto; 
          }
          
           #tablePagination { 
            background-color:  Transparent; 
            font-size: 0.8em; 
            padding: 0px 5px; 
            height: 20px
          }
          
          #tablePagination_paginater { 
            margin-left: auto; 
            margin-right: auto;
          }
          
          #tablePagination img { 
            padding: 0px 2px; 
          }
          
          #tablePagination_perPage { 
            float: left; 
          }
          
          #tablePagination_paginater { 
            float: right; 
          }

Finally, add this script in your ASPX Page:

<script type ="text/javascript" >
	$(document).ready(
 	function() {
 	$('table').tablePagination({});
 	});
 	</script> 

Now, add Gridview1_PreRender method in code behind, unless during paging you cannot see the Header of Gridview. Generally, Gridview does not use tbody, thead, or tfoot tags for the table that is generated when rendered in the browser. So, for Tbody and Thead, we need to add this function:

 protected void GridView1_PreRender(object sender, EventArgs e)
 {
     GridView1.UseAccessibleHeader = false;
     GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;
 }

Configuration

You can change different parameters of jquery.tablePagination.0.1.js. Below are some of the settings from the authors Site:

  • firstArrow - Image - Pass in an image to replace default image.
    Default: (new Image()).src="./images/first.gif"
  • prevArrow - Image - Pass in an image to replace default image.
    Default: (new Image()).src="./images/prev.gif"
  • lastArrow - Image - Pass in an image to replace default image.
    Default: (new Image()).src="./images/last.gif"
  • nextArrow - Image - Pass in an image to replace default image.
    Default: (new Image()).src="./images/next.gif"
  • rowsPerPage - Number - used to determine the starting rows per page.
    Default: 5
  • currPage - Number - This is to determine what the starting current page is. Default: 1
  • optionsForRows - Array - This is to set the values on the rows per page.
    Default: [5,10,25,50,100]
  • ignoreRows - Array - This is to specify which 'tr' rows to ignore. It is recommended that you have those rows be invisible as they will mess with page counts.
    Default: [].

For the Future Release of Table Pagination Plugin

History

  • 10th June, 2009: Initial post

License

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

About the Author

sagnik mukherjee

Web Developer

India India

Member

Follow on Twitter Follow on Twitter
I am from India, currently i am working in Microsoft Platform for building web and mobile applications.

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

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionThis doesnt work if we do a server side Data Bind Pinmembermsdnexpert5:19 7 Oct '11  
QuestionPaging in number Pinmembermegha.khamar@gmail.com0:59 18 Aug '11  
GeneralPrerender method for DataGrid Pinmemberu4bharat2:51 10 Jun '11  
GeneralAdd Pager to a Repeater Pinmembernipunasilva21:52 23 May '11  
GeneralMy vote of 5 Pinmembernipunasilva21:50 23 May '11  
QuestionMissing Images Pinmemberjagman825:43 3 Jan '11  
Generalgridview paging using javascript only not by JQUERY Pinmembernilesh.d.mankar5:31 27 Dec '10  
GeneralMy vote of 4 Pinmemberbhavasinchana4:47 2 Dec '10  
Questionpaging above the grid PinmemberChella S20:57 18 Nov '10  
AnswerRe: paging above the grid Pinmembersagnik mukherjee23:37 21 Nov '10  
GeneralRe: paging above the grid PinmemberChella S21:39 22 Nov '10  
GeneralRe: paging above the grid Pinmembersagnik mukherjee7:33 23 Nov '10  
GeneralRe: paging above the grid PinmemberChella S0:49 25 Nov '10  
Question2grid view and 2 table in one page Pinmembermajid_3ma21:17 2 Nov '10  
Questionpaging with dynamic html table PinmemberGuru_yogi2:39 6 Nov '09  
AnswerRe: paging with dynamic html table PinmemberNeoAlchemy16:15 8 Nov '09  
GeneralRe: paging with dynamic html table PinmemberGuru_yogi19:01 8 Nov '09  
GeneralRe: paging with dynamic html table PinmemberNeoAlchemy19:13 8 Nov '09  
AnswerRe: paging with dynamic html table PinmemberGuru_yogi20:51 8 Nov '09  
Generalhelpful for me Pinmembernicholas_pei17:44 10 Jun '09  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120210.1 | Last Updated 10 Jun 2009
Article Copyright 2009 by sagnik mukherjee
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid