1. Use the built-in paging function of the DataGrid
Add the following statement to the properties of the DataGrid Control:
Allowpaging = "true"
Pagesize = "5"
Pagerstyle-horizontalalign = "right"
Note: allowpaging allows paging. Pagesize indicates the number of records displayed on each page. If not written, 10 records are displayed by default. Pagerstyle-horizontalalign specifies the position of the pagination button. The default value is left.
2. Use SQL statements
Select top @ pagesize * From topic where id not in (select top @ pagesize * @ pagenum ID from topic)
Note: @ pagesize indicates the number of records displayed on each page, and @ pagenum indicates the page number.
In addition, topic is the table name and ID is an identifier 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 number of records read, and pagesize refers to the number of records to read.
4. Use datatable. Rows
For I = nstart to nend
Response. Write (Dt. Rows (I) ("itemname") & "<br>")
Next
Note: nstart refers to the sequence number of the record to be read, and nend refers to the sequence number of the last read record dt