Cause:
The traditional objectdatasource is used as the data source. If you bind a listview, you can insert, delete, update, delete, or pagination data without writing a line of code! Exceptional power! However, the default paging mode of listview is to retrieve all data from the database and display the data after pagination Based on the page number, so what if we can't get specific data from a page? The answer is yes!
Technical steps for efficient paging:
Based on your original program:
Step 1: Create a strongly Typed Dataset
Add two functions:
The first one is: or the total number of data entries in the database querycount
Select count (*) from t_news
The second is: Get a piece of data in the database getpageddata
Select * from
(Select ID, title, MSG, createdate, row_number () over (order by ID) rownum from DBO. t_news) T
Where T. rownum> @StartrowindexAnd T. rownum <= @Startrowindex+ @Maximumrows
A warning is displayed, indicating that the row_number () function cannot be generated but the function is not affected. The result is
Because row_number () cannot be generated, we need to add the parameter of the second function! Function right-click attribute
Final Effect
Step 2: configure the data source objectdatasource for efficient Paging
Reconfigure the data source and select the getpageddata method you just added!
Delete the automatically generated select Method
Add a method to obtain the total number of data manually:
Selectcountmethod = "querycount"
Enable the paging function of the Data source:
Set the number of datapager pages in listview to 10. OK!