复制代码 代码如下:
 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();

华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com