Asp. NET Note line command processing and pagination detailed _ practical skills

Source: Internet
Author: User

1, line command processing

(1, Background code: Operation Line

If this function is from an HTML response
if (e.commandname== "Addage") {

Get line number
int index= ((listviewdataitem) e.item) Dispalyindex;
Gets the primary key value of the current action row
DataKeys saves all IDs, takes 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, sorting
Commandname= "Sort"
Commandargument= "ID"
Internal sort, less efficient

2, DataPager pagination

Pagecontrolid: to which ListView paging



Advanced Paging:



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<20


3, Efficient paging:


(1, Database method:


Get the number of rows on this page
Number of rows started: startRowIndex
Start adding 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 (the order by Id) rownum from dbo. T_user
) T
where t.rownum> @startRowIndex and t.rowrow<= @startRowIndex + @maximumRows

Since the startrowindex+maximumrows two parameters will not help us build, we need to add them manually.

(2, page

* * do not <selectparameters>
* * Add a selectcountmethod= "Querycount" to set the method of obtaining the number of rows
and selectmethod= "Getpagedata "is to get paging information
and enablepaging=" true "
* * ObjectDataSource to configure ListView in normal flow, let ListView automatically generate
and then configure paging data source

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.