ASP.NET provides three powerful list controls: DataGrid, DataList, and Repeater controls, but only DataGrid controls provide paging feature. Relative to DataGrid, DataList, and Repeater controls have higher style customizers, many times we prefer to use the DataList or REPEATER control to display data.
The PageDDataSource class encapsulates the properties of the DataGrid control, which makes the DataGRID to perform paging. Part of the PageDataSource class:
ALLOWCUSTOMPAGING Gets or sets the value indicating whether custom paging is enabled. ALLOWPAGING gets or sets the value indicating whether the paging is enabled. COUNT Gets the number of items to be used from the data source. CurrentPageIndex Gets or sets the index of the current page. DataSource gets or sets the data source. DataSourceCount Gets the number of items in the data source. FirstIndexInPage Gets the first index in the page. IScustomPagingeNableD gets a value that indicates whether custom paging is enabled. ISFirstPage gets a value that indicates whether the current page is homepage. IslastPage gets a value that indicates whether the current page is the last page. ISPagingeNabled gets a value that indicates whether paging is enabled. IsReadOnly gets a value indicating whether the data source is read-only. Issynchronized Gets a value indicating whether to synchronize access (thread security). PageCount Gets the number of pages required to display all items in the data source. PageSize Gets or Sets the number of items to display on a single page. VirtualCount Gets or settings the number of actual items in the data source when using custom paging.
The DataGrid control is to use the PagedDataSource class to implement data pagination display, so DataList and Repeater also use PageDDataSource to display paging.
private void BindData () {// ds filled codes DataView dv = ds.Tables [0] .DefaultView; PagedDataSource Pds = new PagedDataSource (); Pds.DataSource = dv; Pds.AllowPaging = true; Pds.PageSize = 10; int Totalcount = pds.pagecount; int currpage; // You can submit the page index currpage = request.QueryString ["Page"; // Finally Bind // DataList1.DataSource = PDS DataList1.databind ();
Http://www.donews.net/shanyou/archive/2005/02/13/275482.aspx