读取一篇文章并分页显示

  private void BindList()
  {
   this.sqlDataAdapter1.Fill(this.dataSet11);
   DataTable NewDT = this.dataSet11.Tables[0];
   PagedDataSource pds = new PagedDataSource();
   pds.AllowPaging = true;
   pds.DataSource=NewDT.DefaultView;
   pds.AllowPaging=true;
   pds.PageSize=8;

   int CurrentPage;
   if(Request.QueryString["Page"]!=null)
    CurrentPage=Convert.ToInt32(Request.QueryString["Page"]);
   else
    CurrentPage=1;
   pds.CurrentPageIndex=CurrentPage-1;
   int Total = NewDT.Rows.Count;
   lblTitle.Text = "当前共有"+Total+"条数据";
   lblCurrentPage.Text="当前页为第"+CurrentPage.ToString()+"页";
   lblPageCount.Text="共有"+pds.PageCount.ToString()+"页数据";
   if(!pds.IsFirstPage)
   {
    lnkPrev.NavigateUrl=Request.CurrentExecutionFilePath+"?Page="+Convert.ToInt32(CurrentPage-1);
    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;
   }

   this.gbook.DataSource = pds;
   this.gbook.DataBind();
  }
 }
}

posted @ 2005-09-29 08:19  gybsoft  阅读(1089)  评论(3编辑  收藏  举报