DataGrid's efficiency paging

xiaoxiao2021-03-06  51

DataGrid in ASP.NET has built-in paging features, but its default paging mode is very low, especially when the amount of data is large, it is almost impossible to use its built-in paging function because it will Read all the data from the database and then make a paging, this only selects a small portion and throws most of the way is not deserved. In the most intra-one project, it is very large because a management page must be managed because a management page is very large. Therefore, you must display the display, and you cannot use the built-in paging function of DataGrid, so you can implement it yourself. Here, I will introduce the paging method I used in the project. Of course, the control is still used in DataGrid, because data binding is very convenient ^ _ ^ To ensure that the redundant data is not transmitted, the paging must be implemented when data is read in the database, and the paging operation of the database can be placed in the stored procedure. On a Blog of 9CBS, a million-level data paging is told. Implementation of the stored procedure (http://blog.9cbs.net/wellknow/posts/55167.aspx, his method can be appropriately optimized according to different situations), according to his method, here is a simple SQL statement Implement the stored procedure required here page. Create Procedure ListProduct (@PageIndex Int, - page number @Pagesize Int, - 1 page size @Conditionsql - SQL statement for query criteria) AS ... The specific code is not written (you can refer to the link above) specifically the following SQL statement: SELECT TOP 100 * fROM (select * from product where productid <200000) T WHERE T.productid NOT iN (SELECT TOP 900 productid fROM (select productid from product where productid <200000) T1 ORDER BY T1. ProductID ASC) ORDER by ProductID ASC This statement removes ProductID <200000 ($ 200,000) from total commodity (300,000), then press the size pagination per page, then remove pages 10. Public DataTable ListProduct (int PageIndex, int pageize) {//ado.net The code to remove the data from the database is ^ _ ^.} The data read by the above stored procedure is paised in DataGrid, and the dataGrid's allowpaging and allowcustomPaging must be set to true protected System.Web.UI.WebControls.DataGrid ProductGrid; ProductGrid.AllowPaging = true; ProductGrid.AllowCustomPaging = true; then provided to a display size ProductGrid.PageSize = 100; // based on actual data is displayed at the time display.

转载请注明原文地址:https://www.9cbs.com/read-116199.html

New Post(0)