ASP. NET Repeater controls implement simple paging, asp. netrepeater

Source: Internet
Author: User

ASP. NET Repeater controls implement simple paging, asp. netrepeater

In the morning, I saw MSDN.

PagedDataSource class

Http://msdn.microsoft.com/zh-cn/library/system.web.ui.webcontrols.pageddatasource (v = vs.110). aspx

Remember that in the past, Insus. NET only customized pages for the Gridview and DataList controls. GridView and DataList paging components and User Controls. You can only use the Repeater control to bind a single record or use a small dataset.


Today, I saw the MSDN paging class, and I didn't see Microsoft listing the Repeater control. Can't I really paging the Repeater control?

 
Demo:
Prepare the data source from the database:


There is an instantiation class BizBaseSQLSp above, the specific implementation of this class, can refer to ASP. NET development, from the second layer to the third layer, To object-oriented (3) http://www.cnblogs.com/insus/p/3826706.html

Set the Style of the Repeater control ):

 

After creating the Repeater control:

Set the paging status:

 

Now we can implement the. cs Page code, implement paging status, and bind the Reeapter control. before implementation, we need to write a property to store the Index of the current page:


Implement paging and data binding controls:



There are two button events not implemented, and we will complete them below:

 

 

Implementation Demonstration:




Pagination of the Repeater control in ASPNET

Repeater1.DataSource = (DataSet data source)
Repeater1.DataBind ();

ASPNET supports repeater paging, c #

// Pagination during data access
Data Access paging sorting method

Int pageId: Current page,
Int pageSize,
String addWhere query condition,
String taxisName: name of the column to be sorted,
String descOrAsc: two sort parameters (desc/asc ),
String tableName: data table name

Public static DataSet getDataSet (int pageId, int pageSize, string addWhere, string taxisName, string descOrAsc, string tableName)
{
String SQL = "select * from (select ROW_NUMBER () OVER (ORDER BY" + taxisName + "" + descOrAsc + ") as pageId, * from" + tableName + ") as tablename ";
SQL + = "where pageId> =" + (pageSize * (pageId-1) + 1 ). toString () + "and pageId <=" + (pageSize * pageId ). toString () + "" + addWhere;
Return DbHelperSQL. Query (SQL );
} // This method has the SQL injection vulnerability in SQL statements. It can be used to determine whether user input is legal based on user input conditions and prevent SQL injection into baidu from providing a lot of information.
All the parameters are available, so do it.
You can change the parameter value for any page and number of data records per page.

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.