ASP.NET Custom Paging
How to keep custom paging for dynamic result sets ? (i.e) based on 10 Dropdowns selection my stored procedure will Dynamically generates resultset,but it populates million records.
Row statically know Record count,cusom pagin开发者_StackOverflowg is efficient,but how to achieve it for dynamically grown result set?
Problem
I have to bind generic List to GridView,Columns are fixed,but the number of rows retuened are unknown,but without custom paging my GridView took 30 minutes to populate the result.
If possible, you should use LINQ, as the extensible operations make for easy paging.
Essentially, you would specify an ObjectDataSource or LinqDataSource for your GridView.
You would then have an IQueryable<T>
method which accepts a starting position and number of rows to retrieve.
Then you make use of Skip()
and Take()
to achieve simple paging.
Here's a very good article on doing that.
Remember that Skip()
and Take()
are methods exposed to any class which implements IEnumerable. So even though the above article uses LINQ-SQL for their data repository, as long as your own DAL exposes a collection of type IEnumerable
, you can use the Skip and Take pattern.
Hope that helps.
An easy way to do this server side would be to use LINQ. Took at the .Take() method.
精彩评论