Click here to Skip to main content
11,480,031 members (65,474 online)
Click here to Skip to main content
Add your own
alternative version

Custom paging with ASP.NET GridView

, 26 Jun 2012 CPOL 85.6K 3.6K 35
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,
Follow on   Google+

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150520.1 | Last Updated 26 Jun 2012
Article Copyright 2012 by tanweer
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid