How to deal with Line Command and Page in ASP.NET
This article mainly introduces how to deal with line commands and paging in ASP.NET. It is very detailed and has a certain reference value. Friends who are interested must finish reading it.
1. Line command processing
(1) background code: operation line
/ / if it comes from the function operation in the html response
If (e.CommandNameplate = "addAge") {
/ / get the line number
Int index= ((ListViewDataItem) e.Item) DispalyIndex
/ / get the primary key value of the current operation line
/ / DataKeys stores all the ID and fetches the index ID
Guid id= (Guid) ListView1.DataKeys [index] .value
Table Adapter adapter=new Table Adapter ()
Adpter. Custom database function addAge
/ / data binding
ListView.DataBing ()
}
(2) sort
CommandName= "Sort"
CommandArgument= "ID"
Internal sorting, low efficiency
2. DataPager paging
PageControlID: which ListView is paged
Advanced pagination:
Query subquery
Select* from
(Select id,name,age,row_number () over (order by id) rownum from T_Users) t
Where t.rownum > 11and t.rownum@startRowIndex and t.rowRow