Several paging methods in ASP.NET

xiaoxiao2021-03-06  37

1, use DataGrid's built-in paging function

Add the following statement in the properties of the DataGrid control, sopaging = "true" PageSize = "5" Pagersty-Horizontalalign = "Right"

Note: AllowPaging refers to the allowable paging. PageSize is the number of records that specify each page, if not, it will default to 10. PagersTyle-Horizontalalign is the positioning of the paging display button, which is left by default.

2, use SQL statement

SELECT TOP @Pagesize * from topic where id not in (select top @ PageSize * @ Pagenum ID from topic)

Note: @PageSize is the number of records that specify each page, @ Pagenum refers to the shortest page. In addition, Topic is a table name, ID is a identity column.

3, use dataset.fill

DataSet ds = new DataSet (); SqlDataAdapter MyAdapter = new SqlDataAdapter (strSel, Conn); MyAdapter.Fill (ds, StartIndex, PageSize, "guest");. Mydatalist.DataSource = ds.Tables [ "guest"] DefaultView;

Note: StartIndex refers to the reading of the first few records, and PageSize means how many records to read

4, use DataTable.Rows

For i = nStart to Nendresponse.write (Dt.Rows (i) ("ItemName") & "
") Next

Note: NStart refers to the serial number of the record that starts reading, and the nend refers to the serial number DT of the last read record is a DataTable object.

转载请注明原文地址:https://www.9cbs.com/read-62148.html

New Post(0)