Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
I want asp code for paging in grid view.
Thanks for ur replay.
Posted

 
Share this answer
 
Hi,

In your source code of Grid, you must set the pagging property to "true" and call the page index method in code behind itself and rebind your grid in that method itself.

in source code:

C#
AllowPaging="True"  onpageindexchanged="gdDocument_PageIndexChanged" PageSize="50"


In code behind:

C#
gdDocument.CurrentPageIndex = e.NewPageIndex;
//rebind your DB..
 
Share this answer
 
Follow the steps below:

  • Set the AllowPaging property to true in HTML Source of GridView.
  • Go to PageIndexChanging event of your GridView.
  • Set the PageIndex as NewPageIndex.
  • Bind the GridView again.

Example:
C#
protected void gvUsers_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    gvUsers.PageIndex = e.NewPageIndex;
    gvUsers.DataSource = YourDataSource;//This should be your gridview datasource.
    gvUsers.DataBind();
}



--Amit
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900