Click here to Skip to main content
15,893,814 members
Articles / Web Development / ASP.NET

Custom paging for Gridview, DataGrid, DataList and Repeater Control in ASP.Net with C#

Rate me:
Please Sign up or sign in to vote.
3.86/5 (4 votes)
2 Jan 2009CPOL3 min read 75.5K   3.5K   46  
with the help of following code, you can ao=pply custom paing in
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="custom.aspx.cs" Inherits="custom" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Custom Gridview Paging</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        
   
    <asp:GridView ID="GridView1" runat="server">
    </asp:GridView>
    <br />
    <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
    
   
    
       <input type="hidden" value="6" id="PageSize" runat="server"/>
        <input type="hidden" value="1" id="CurrentPage" runat="server"/>
        <input type="hidden" id="TotalSize" runat="server"/>
     
        <table align="right">
               <tr>
                <td>
                    <asp:LinkButton ID="first" runat="server" Text="<< First" OnClick="first_Click" CausesValidation="false" CssClass="blue_boldtext_link"></asp:LinkButton>
                    &nbsp;&nbsp;
                    <asp:LinkButton ID="prev" runat="server" Text="< Previous" OnClick="prev_Click" CausesValidation="false" CssClass="blue_boldtext_link"></asp:LinkButton>
                    &nbsp;&nbsp;
                    <asp:Label ID="lblPaging" runat="server"></asp:Label>
                    &nbsp;&nbsp;
                    <asp:LinkButton ID="next" runat="server" Text="Next >" OnClick="next_Click" CausesValidation="false" CssClass="blue_boldtext_link"></asp:LinkButton>
                    &nbsp;&nbsp;                    
                    <asp:LinkButton ID="last" runat="server" Text="Last >>" OnClick="last_Click" CausesValidation="false" CssClass="blue_boldtext_link"></asp:LinkButton>
                </td>
                </tr>
        </table>
    
     </div>
    </form>
</body>
</html>

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.

License

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


Written By
Web Developer
India India
The Author belonges to Almora, Uttarakhand, Northern part of India and one of the awesome and less explored. he was interested in microsoft technologies from his college days. he is also a regular contributor for http://forums.asp.net and many others. Currently associated with an reputed firm in India.

Comments and Discussions