1. Line command processing
(1. Background code: operation line
// If this function operation is from the html response
If (e. CommandName = "addAge "){
// Obtain the row number
Int index = (ListViewDataItem) e. Item) DispalyIndex;
// Obtain the primary key value of the current operation row
// DataKeys stores all IDs and obtains the index ID.
Guid id = (Guid) ListView1.DataKeys [index]. Value;
Table Adapter adapter = new table Adapter ();
Adpter. User-Defined database function addAge;
// Data Binding
ListView. DataBing ();
}
(2) sorting
CommandName = "Sort"
CommandArgument = "ID"
Internal sorting with Low Efficiency
2. DataPager page
PageControlID: To which ListView is displayed
Advanced paging:
Query subqueries
Select * from
(Select id, name, age, row_number () over (order by id) rownum from T_Users) t
Where t. rownum> 11and t. rownum <20
3. Efficient paging:
(1. Database methods:
// Obtain the number of rows on the current page
Start row: startRowIndex
Start to add the number of rows on this page: startRowIndex + maximumRows
// Database method: GetCount
Select Count (*) from T_Users
// Database method name: QueryCount
Select * from
(
Select Id, Name, Gender, Row_Number () over (order by Id) rownum FROM dbo. T_User
) T
Where t. rownum> @ startRowIndex and t. rowRow <= @ startRowIndex + @ maximumRows
Because the startRowIndex + maximumRows parameters are not generated for us, we need to manually add them.
(2) Page
** Do not <SelectParameters>
** Added a SelectCountMethod = "QueryCount" method to set the number of rows to be retrieved.
SelectMethod = "GetPageData" is used to obtain paging information.
And EnablePaging = "true"
** First configure the objectDataSource of the ListView according to the normal process, so that the ListVIew will automatically generate
Configure the paging data source again