复制代码 代码如下:
 PagedDataSource objPage = new PagedDataSource();

            DataView dv = bllBook.GetListByState("", true);
            //设置数据源
            objPage.DataSource =dv ;

            //允许分页
            objPage.AllowPaging = true;

            //设置每页显示的项数
            objPage.PageSize = 10;


            //定义变量用来保存当前页索引
            int CurPage;
            int RecordCount;
            int PageCount = objPage.PageCount;

            RecordCount = dv.Count;

            //判断是否具有页面跳转的请求
            if (Request.QueryString["Page"] != null)
            {
                CurPage = Convert.ToInt32(Request.QueryString["Page"]);
            }

            else
            {
                CurPage = 1;
            }

            //设置当前页的索引
            objPage.CurrentPageIndex = CurPage - 1;

            //显示状态信息
            lblCurPage.Text = "第  " + CurPage.ToString() + "/" + PageCount.ToString() + "页    共  " + RecordCount.ToString() + " 记录 ";

            //如果当前页面不是首页
            if (!objPage.IsFirstPage)
            //定义 "上一页 "超级链接的URL为:当前执行页面的虚拟路径,并传递下一页面的索引值
            {
                lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1);
                lnkFirst.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(1);
            }

            //如果当前页面不是最后一页
            if (!objPage.IsLastPage)
            //定义 "下一页 "超级链接的URL为:当前执行页面的虚拟路径,并传递下一页面的索引值
            {
                lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);
                lnkLast.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(PageCount);
            }

            //进行数据绑定
            Repeater1.DataSource = objPage;
            Repeater1.DataBind();

标签:
repeater,PageDataSource

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com