ASP. NET notes-line command processing and paging details

Source: Internet
Author: User

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

Related Article

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.