简体   繁体   中英

Display records page wise using ASP.NET with C#

I have created web page that retrieves data from MS SQL database and display it to the user in well formatted manner. Data retrieved depend upon criteria selected by the user. But sometimes data retrieved is very large. I want to display records to the user page wise, ie 100 records on first page and next 100 records displayed when user clicks next button. This means only 100 records should be retrieved when user first select search criteria, next 100 records retrieved when he clicks next button and so on, as to reduce data transferred from server to client.

Please suggest me how to achieve this as soon as possible. Thanks in advance.

What you are looking for is called paging .

This can be done a million ways. You mention jquery, javascript and asp.net. For displaying purpose that is quite all righ but for good performance you want to make sure that the actual selection of the page has to be done at the backend.

One approach is this: http://msdn.microsoft.com/en-us/library/aa479347.aspx This is not jquery but it shows a way to do it.

You can use jqGrid or DataTables . Both are very popular grids

Ask user to set there criteria and then render the grid according to that.

If you want simple fast and way then think in using jQuery plugins like these

jpaging OR datatables .

you should search for design pattern for this.

kindly look at this Easily build powerful client-side AJAX paging, using jQuery

Your use of both asp.net and C# makes me (probably because I am partial to it) think "WebMatrix". If, indeed you are using WebMatrix, check out its Grid Helper. However, be warned that this method can generate some very serious overhead for your html page (by that I mean that if you query 1,000 rows and only use 100 per page, it will retrieve all 1,000, use 100, and waste the other 900). Also, using the WebGrid generates the results in a table, which may not be your preferred style.

Alternatively (still thinking "WebMatrix"), you could use this article here (this is my preferred method): http://www.mikesdotnetting.com/Article/150/Web-Pages-Efficient-Paging-Without-The-WebGrid

Don't worry, that article is explained with EXCELLENT brevity and accuracy (and explained better than I could, so I leave it to Mike to vicariously answer that one).

1) If you are looking for web grid then it is possible, you have to manage paging at the bottom of grid. this article will help you

http://stick2basic.wordpress.com/2013/02/20/asp-net-mvc-web-grid-with-efficient-paging/

2) one more option for it "Load data as you scroll down" for this you can refer this.

http://stick2basic.wordpress.com/2013/03/09/load-data-while-scrolling-page-down-with-jquery-in-asp-net-2/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM