Advertisements

Wednesday, November 13, 2013

// // Leave a Comment

Pagination in GridView

Hi,
Simply we will learn here how to Apply Pagination in ASP.NET GridView Control.
Directly to Code:
In ASPX page, enable paging in GridView.

<asp:GridView ID="gvAllPOD" runat="server" AutoGenerateColumns="false" 
AlternatingRowStyle-BackColor="LightSeaGreen" HeaderStyle-Font-Bold="true" 
AllowPaging="true" PageSize="20" onpageindexchanging="gvAllPOD_PageIndexChanging">

In Above Code, we Automatically Generated Columns from DataSource Then AllowPaging = True, so that GridView Data can be Paged, Also We defined PageSize that what amount of Records whould display in Page.
To Apply Pagination, RIght Click in GridView and Choose Properties > Events. Choose PageIndexChanged event and Place Following code in ASPX.CS Page.
protected void gvAllPOD_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvAllPOD.PageIndex = e.NewPageIndex;
        BindGVAllPOD();
    }

Now Check on your Page. What is Happening on Clicking Page Number. You can comment if some queries on above code.
John Bhatt
Glad to Know, Free to Share

Tags: Pagination, Paging, GridView, ASP.NET, Disply data in Page, Tutorial bt John Bhatt

0 comments:

Post a Comment

Leave your Feedback or Suggestion. We will be Happy to read and reply.