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.