Click here to Skip to main content
16,009,598 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more: (untagged)
Hi,
Sorry, if this question is stupid but i have tried searching alot and couldn't find an exact answer. Also, i am not looking for an exact solution but guidance in the right direction would be highly appreciated.

I realize that gridview paging selects all data but displays a portion of it. I want to implement custom paging where data is only specific data is selected. I have kind of done my homework on it. ie i can use linq to select and skip data, but i want page links to be displayed at the bottom of the page. Is there any property that sets this (i believe datagrid had virtualitemcount). Does gridview has something like this or do i need to program this portion. I would like to mention here that i don't want to use SqlDataSource or ObjectDataSource, rather i want to assign datatable to gridview.DataSource. Again, would i have to manage paging my self, if i implement above solution.

Sorry, if its a stupid question. Again i found solutions on google but none had numbered pages in bottom of gridview, which i want to have. I can do it with next,prev btn at the moment.

Thankyou very much
Posted

1 solution

mark_me wrote:
i can use linq to select and skip data


I don't know anything about the problem domain you are working on and data structures you use. But if database is your persisting area, efficient way to do this is to get only rows that will be displayed.

mark_me wrote:
Again i found solutions on google but none had numbered pages in bottom of gridview, which i want to have. I can do it with next,prev btn at the moment.


IMO, there is nothing wrong in using ObjectDataSource since it comes with inbuilt paging capabilities. If you are binding a DataTable, you need to set the TypeName property to DataTable.

You need to provide two methods, one for selecting the data according to the page number and another method for calculating the total count of data. These methods should be assigned to SelectMethod and SelectCountMethod properties respectively.

Scott Guthrie's article[^] gives an overview of doing this. He is using ASP.NET AJAX but the concepts are same.

:)

 
Share this answer
 


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