Repeater控件分页

private int pagesize=10;//一页显示的条数
 private void loadData()
        {
            int nowpage = int.Parse(Label2.Text);//当前页计数器
            PagedDataSource pds = new PagedDataSource();

DataSet ds = new website.BLL.Power().GetList(strWhere);
if (ds != null && ds.Tables[0].Rows.Count > 0) { pds.DataSource = ds.Tables[0].DefaultView; pds.AllowPaging = true;//是否启用分页
                pds.PageSize = pagesize;//一页显示的条数
                pds.CurrentPageIndex = nowpage - 1;//获取当前页的索引
                if (nowpage == 1)//如果是第一页,上一页和第一页按钮不可用
 { this.lone.Enabled = false; this.lup.Enabled = false; } if (nowpage == pds.PageCount)//如果是最后一页,下一页和最后一页按钮不可用
 { this.ldown.Enabled = false; this.llast.Enabled = false; } this.Label1.Text = "总共:" + pds.PageCount + "";//总页面数
                this.Repeater1.DataSource = pds; this.Repeater1.DataBind(); } else { this.lone.Enabled = false; this.lup.Enabled = false; this.ldown.Enabled = false; this.llast.Enabled = false; } }

你可能感兴趣的:(分页)