Click here to Skip to main content
15,904,494 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
How to add in gridview in pagnation in code behind
C#
GridView1.AllowPaging = true;
              GridView1.PageSize = 10;
              GridView1.DataBind();
              GridView1.EnableSortingAndPagingCallbacks = true;


i add this code in code behind..
It is not working...

Please say correct solution Friends!

Advance Thanks Friends!
Posted
Comments
PrashantSonewane 10-Apr-13 0:48am    
Make sure you have more than 10 records while testing. :)
Try setting pagination properties in page load. However it is as good as setting at design time. Pagination will show the pages if number of records exceed than 10. I don't think you need to change the pagination property. Number of Rows you can change dynamically.
Rekhash 10-Apr-13 1:34am    
@PrashantSonewane i tried it is also not working...

You should do it with PageIndexChanging.. Hope this helps:
C#
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    GridView1.PageIndex = e.NewPageIndex;
    GridView1.DataSource = //get datasource (list or datatable)
    GridView1.DataBind(); //bind data
}
 
Share this answer
 
Comments
Rekhash 10-Apr-13 5:20am    
@PetarS089 i am using tabs controls in aps.net
Try In page load events...
C#
GridView1.AllowPaging = true;
GridView1.PageSize = 10;
GridView1.EnableSortingAndPagingCallbacks = true;
 GridView1.DataSource =dataset;
GridView1.DataBind();
 
Share this answer
 
Comments
Rekhash 10-Apr-13 5:40am    
@KM Perumal
i tried 4 ways in grid view... If i click page2 means it wont move page 1 to page 2
We can use in Multi-View in aps.net using c# in asp.net in gridview,...
 
Share this answer
 

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