zoukankan      html  css  js  c++  java
  • repeater分页实例

    //        初始化分页类

    PagedDataSource Pgds=new PagedDataSource();
    //        获取数据源

       Pgds.DataSource=CreateDataSource().DefaultView;也可以Pgds.DataSource=List<News>();任何数据集都可
    //        设置允许分页
       Pgds.AllowPaging=true;
    //        每页显示为6行
       Pgds.PageSize=6;
    //        显示总共页数,lblTotalPage为lable控件
       lblTotalPage.Text=Pgds.PageCount.ToString();
    //        当前页
       int CurrentPage;
    //        请求页码为不为null设置当前页,否则为第一页
       if(Request.QueryString["Page"] != null)
       {
        
        CurrentPage = Convert.ToInt32(Request.QueryString["Page"]);
       }

       else
       {

        CurrentPage = 1;
       }
    //   当前页所引为页码-1
       Pgds.CurrentPageIndex = CurrentPage - 1;
    //   显示当前页码
       lblCurrentPage.Text = CurrentPage.ToString();
    //   如果不是第一页,通过参数Page设置上一页为当前页-1,否则不显示连接
       if(!Pgds.IsFirstPage)
       {
        //            Request.CurrentExecutionFilePath为当前请求虚拟路径
        lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurrentPage - 1);
       }
    //        End If
    //   如果不是最后一页,通过参数Page设置下一页为当前页+1,否则不显示连接
       if(!Pgds.IsLastPage)
       {
    //    Request.CurrentExecutionFilePath为当前请求虚拟路径
        lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurrentPage + 1);
       }
    //   模板绑定数据源  
       Repeater1.DataSource = Pgds;
       Repeater1.DataBind();

  • 相关阅读:
    oracle操作小常识
    Report Machine
    ReportMachine
    如何创建Asp.net MVC ViewModel
    Page Scroll Menu (页面中锚点菜单)
    EF selection expression 与 Linq备忘
    chrome 浏览器 开发者工具 性能检测 参数解释
    IE 兼容性写法
    Asp.net MVC Bundle 的使用与扩展
    ASP.NET MVC 性能优化总结
  • 原文地址:https://www.cnblogs.com/dachuang/p/2859367.html
Copyright © 2011-2022 走看看