- private void Bind()
- {
- DataTable table = Goods.getlist();
- if (table.Rows.Count > 0)
- {
- PagedDataSource objPds = new PagedDataSource();
- objPds.DataSource = table.DefaultView;
- objPds.AllowPaging = true;
- objPds.PageSize = 9;
- this.countlabel.Text = "共:" + objPds.PageCount.ToString() + "页";
- int CurPage;
- if (Request.QueryString["Page"] != null)
- CurPage = Convert.ToInt32(Request.QueryString["Page"]);
- else
- CurPage = 1;
- objPds.CurrentPageIndex = CurPage - 1;
- this.currentlabel.Text = "当前页:" + CurPage.ToString();
- if (!objPds.IsFirstPage)
- {
- this.firstlinkbutton.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1";
- //this.firstlinkbutton.Text = "首页";
- this.prevlinkbutton.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1);
- }
- if (!objPds.IsLastPage)
- {
- this.newlinkbutton.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);
- this.lastlinkbutton.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + objPds.PageCount.ToString();
- }
- this.gvgoods.DataSource = objPds;
- this.gvgoods.DataBind();
- }
- }
PagedDataSource应用
最新推荐文章于 2017-10-11 14:00:00 发布
本文介绍了一个使用 ASP.NET 和 C# 实现的商品列表分页功能。通过获取商品数据并利用 PagedDataSource 控件进行分页处理,实现了当前页码、总页数的显示以及导航按钮的功能。

2628

被折叠的 条评论
为什么被折叠?



