Click here to Skip to main content
13,288,869 members (66,362 online)
Click here to Skip to main content


37 bookmarked
Posted 26 Jun 2012

Custom paging with ASP.NET GridView

, 26 Jun 2012
Easy way to implement ASP.NET GridView paging .
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <title>bravi Custom Paging</title>
    <script type="text/javascript" src=""></script>
    <link href="styles.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(document).ready(function () {
            $('#A1').click(function () {
            $('#A2').click(function () {
        function Loadpage() {
            try {
                //reload page using new page size
                var url = $(location).attr('href');
                var index = "Index=1";
                if (url.indexOf('Index') > 0) {
                    index = url.split('?')[1];
                    index = index.split('&')[0];
                url = url.split('?')[0] + "?" + index + "&Size=" + $('#hdSize').val() + "";
                window.location.href = url;
            } catch (e) {
    <form id="form1" runat="server">
    <input type="hidden" runat="server" id="hdSize" />
        <asp:GridView ID="gvPaging" runat="server" AutoGenerateColumns="false" GridLines="None">
                                <td class="text">
                                    Customer ID:
                                <td align="left" colspan="5">
                                    <%# Eval("CustomerID")%>
                                <td align="left" colspan="4" class="text">
                                    Employee ID:
                                    <%# Eval("EmployeeID") %>
                                <td align="left" colspan="4" class="text">
                                    Ship Name:
                                    <%# Eval("ShipName")%>
                                <td align="left" colspan="4" class="text">
                                    Ship Country:
                                    <%# Eval("ShipCountry")%>
                                <td colspan="6">
                                    <hr />
        <div class="pager fl">
            <asp:Label runat="server" ID="lblpre"></asp:Label>
            <asp:Label runat="server" ID="lblIst" Visible="false"></asp:Label>
            <asp:Label runat="server" ID="spDot1" CssClass="page-numbers prev" Visible="false"
            <asp:PlaceHolder ID="pl" runat="server"></asp:PlaceHolder>
            <asp:Label runat="server" ID="spDot2" Visible="false" CssClass="page-numbers prev"
            <asp:Label runat="server" ID="lblLast" Visible="false"></asp:Label>
            <asp:Label runat="server" ID="lblnext"></asp:Label>
        <div class="pager f2">
            <a id="A1" href="javascript:void(0);" runat="server" class="page-numbers">10</a>&nbsp;
            <a href="javascript:void(0);" id="A2" runat="server" class="page-numbers">15</a><span
                class="page-numbers desc">per page</span>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


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


About the Author

Software Developer LIFELONG Pakistan, Islamabad
Pakistan Pakistan
Software Engineer at LIFELONG Pakistan,

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171207.1 | Last Updated 26 Jun 2012
Article Copyright 2012 by tanweer
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid