Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I mean i make a class in app_code folder and use it in whole project for pagination. AS customize paging fetch only required data while grid view paging fetch whole data. Thanks
Posted

Ya,
Create a function in class like,

C#
public void GV_Paging(GridViewPageEventArgs e, DataTable dt, GridView gvOrders)
   {
       gvOrders.PageIndex = e.NewPageIndex;
       gvOrders.DataSource = dt.DefaultView;
       gvOrders.DataBind();
   }

And call this function on PageIndexChanging event of Gridview in your code page like,

cmn.GV_Paging(e, dt, gvOrders);


Where cmn : object of class
dt : datasource of your gridview
gvOrders : Id of Gridview
 
Share this answer
 
Comments
mohit _srivastava 23-Jan-12 1:18am    
thank u supriya but having a 1 more doubt that my grid view for whole project should me of equal no of columns
Supriya Srivastav 23-Jan-12 1:23am    
No,when passing source of your gridview,it just binds gridview having whatever columns.
mohit _srivastava 23-Jan-12 1:32am    
ok thank u now i am going to try it...
Thank u
mohit _srivastava 23-Jan-12 2:30am    
supriya everything is fine but one problem comes that pagination link in grid view doesn't comes second time as second time data fetch from database is equal to the page size.

so what to do..
Supriya Srivastav 23-Jan-12 3:25am    
Are paging links invisible....
Yes you can create a common class for implementing paging for all pages. I have used LINQ to SQL approach for my project and paging implementation is done using the same. The common approach for paging depends on how you design your application for interacting with the database.
 
Share this answer
 
Comments
mohit _srivastava 23-Jan-12 2:40am    
can you please give a simple example as i am new in this.


I am using grid view in whole project and wants to apply customize paging.
so how can i do with.
I want to code one pagination file and use every where in project but don't know how????


Thanks in advance..

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