PagedDataSource应用

 
  1.         private void Bind()
  2.         {
  3.             DataTable table = Goods.getlist();
  4.             if (table.Rows.Count > 0)
  5.             {
  6.                 PagedDataSource objPds = new PagedDataSource();
  7.                 objPds.DataSource = table.DefaultView;
  8.                 objPds.AllowPaging = true;
  9.                 objPds.PageSize = 9;
  10.                 this.countlabel.Text = "共:" + objPds.PageCount.ToString() + "页";
  11.                 int CurPage;
  12.                 if (Request.QueryString["Page"] != null)
  13.                     CurPage = Convert.ToInt32(Request.QueryString["Page"]);
  14.                 else
  15.                     CurPage = 1;
  16.                 objPds.CurrentPageIndex = CurPage - 1;
  17.                 this.currentlabel.Text = "当前页:" + CurPage.ToString();
  18.                 if (!objPds.IsFirstPage)
  19.                 {
  20.                     this.firstlinkbutton.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1";
  21.                     //this.firstlinkbutton.Text = "首页";
  22.                     this.prevlinkbutton.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1);
  23.                 }
  24.                 if (!objPds.IsLastPage)
  25.                 {
  26.                     this.newlinkbutton.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);
  27.                     this.lastlinkbutton.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + objPds.PageCount.ToString();
  28.                 }
  29.                 this.gvgoods.DataSource = objPds;
  30.                 this.gvgoods.DataBind();
  31.             }
  32.         }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值