One of the REPEATERDATALIST paging method

xiaoxiao2021-03-06  14

About the Repeater and DataList control paging, I am used to implement two ways, one is to use the PageDataSource class to implement, relatively simple, method is as follows:

public void ListBind () {myConn = new OleDbConnection ( "Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" Server.MapPath ( "/ data / data.mdb")); OleDbDataAdapter myComm = new OleDbDataAdapter ( "select * from guestbook order by gbdate desc ", myconn); DataSet DS = New Dataset (); Mycomm.Fill (DS," Guestbook ");

PagedDataSource PDS = New PagedDataSource (); pds.datasource = ds.tables ["guestbook"]. Defaultview; pds.allowpaging = true; pds.pagesize = 8;

int CurrentPage; (! Request.QueryString [ "Page"] = null) if CurrentPage = Convert.ToInt32 (Request.QueryString [ "Page"]); else CurrentPage = 1; pds.CurrentPageIndex = CurrentPage-1; lblCurrentPage.Text = CurrentPage.ToString (); lblPageCount.Text = pds.PageCount.ToString (); if (pds.IsFirstPage!) {lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath Convert.ToInt32 (CurrentPage-1) "Page =?"; lnkFirst. NavigateUrl = Request.CurrentExecutionFilePath "Page = 1?";} if (! pds.IsLastPage) {lnkNext.NavigateUrl = Request.CurrentExecutionFilePath "? Page =" Convert.ToInt32 (CurrentPage 1); lnkLast.NavigateUrl = Request.CurrentExecutionFilePath "? Page =" pds.pagecount;} dlstguestbook.DataSource = pds; dlstguestbook.database ();

http://dotnet.mblogger.cn/rainc/posts/2578.aspx

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

New Post(0)