开发者

How to avoid the grid view in asp.net not to post the page to the server on paging

开发者 https://www.devze.com 2022-12-15 19:33 出处:网络
I\'ve a grid view, with IList as a datasource. I\'ve thousands of records and so I\'ve used pagination. The grid view will display only 10 records per page. My question is, how to avoid the grid开发者

I've a grid view, with IList as a datasource. I've thousands of records and so I've used pagination. The grid view will display only 10 records per page. My question is, how to avoid the grid开发者_如何学C view making DB calls again to the server when I click the 2nd page. Since I load all the data in a collection(IList), I need to iterate within the IList to bind data to the grid view when the next page is clicked. How can I accomplish this ? Help appreciated.


As you mentioned you have thousands of records I prefer you stay on database calls, you can reduce response time by bringing data in chunks like if you are showing 10 rows in grid view only bring 10 rows from the database. You can write a stored procedure where you can specify page size, start position, search criteria as parameters and change as per your need.


If you don't want to hit the database between postbacks during pagination, you need to store the list in memory somehow, perhaps using the Session property of the page, and then bind to that list. If the list can grow large (you mention thousands of records) I would recommend you to consider going via the database anyway, since that will preserve server memory.

0

精彩评论

暂无评论...
验证码 换一张
取 消