DATALIST 的翻页

  PagedDataSource pds = new PagedDataSource();   
//这里用的IBatis for NET 做的,可以用普通的DATASET             
                pds.DataSource = Mapper.Get().QueryForList<GoodPerson>("BaseSelectGoodPerson", null);
                pds.AllowPaging = true;
                pds.PageSize = 4;

                int curPage;
                if (Request.QueryString["Page"] != null)
                {
                    curPage = Int32.Parse(Request.QueryString["Page"].ToString());
                }
                else
                {
                    curPage = 1;
                }

                pds.CurrentPageIndex = curPage - 1;

               
                //lblCurPage为显示当前页的Lable控件
                lblCurPage.Text = "当前页: 第" + curPage.ToString() + "页,"+"共 " + pds.PageCount + " 页";

                if (!pds.IsFirstPage)
                {
                    this.lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(curPage - 1);
                }
                if (!pds.IsLastPage)
                {
                    this.lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(curPage + 1);
                }

 

                dtljytj.DataSource = pds;
                dtljytj.DataBind();

原文地址:https://www.cnblogs.com/mxh691/p/1219229.html