zoukankan      html  css  js  c++  java
  • datalist 分页

    前台:
       <webdiyer:AspNetPager SubmitButtonClass="buttons"  ID="AspNetPager1" runat="server" AlwaysShow="True" FirstPageText="首页"
                            NextPageText="下一页" PrevPageText="前一页" LastPageText="尾页" PageSize="15" ShowInputBox="Always"
                            OnPageChanged="AspNetPager1_PageChanged">
                        </webdiyer:AspNetPager>   
       <!-- PageSize="15"定义每页显示数据条数 -->
    后台:
            /// <summary>
            /// 加载事件
            /// </summary>
            protected void Page_Load(object sender, EventArgs e)
    
            {
             BoundList();
             }
           /// <summary>
            /// 全局的变量,分页用的参数数据信息总数
            /// </summary>
            public static int sumcount;
            /// <summary>
            /// 绑定信息数据
            /// </summary>
            private void BoundList()
            {
                DataTable dt = GetList().Tables[0];//获取数据源
                
                if (dt.Rows.Count > 0)
                {
                    sumcount = dt.Rows.Count;
                    PagedDataSource pds = new PagedDataSource();
                    AspNetPager1.RecordCount = sumcount;
                    pds.AllowPaging = true;
                    pds.PageSize = AspNetPager1.PageSize;
                    pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
                    pds.DataSource = dt.DefaultView;
                    this.gridView1.DataSource = pds; //可以绑定到Gridview 、datalist等数据控件上,此处为Gridview
                    this.gridView1.DataBind();
                }
                else
                {
                    AspNetPager1.RecordCount = 0;
                    this.gridView1.DataSource = null;
                    gridView1.EmptyDataText = "没有相关信息!";
                    this.gridView1.DataBind();
                }
            }
    
            /// <summary>
            /// 分页控件的翻页事件
            /// </summary>
            protected void AspNetPager1_PageChanged(object sender, EventArgs e)
            {
                BoundList();
            }
  • 相关阅读:
    Spring AOP概念理解
    五分钟快速掌握RPC原理及实现
    Linux常用命令汇总
    一致性哈希算法原理
    RPC原理及实现
    IO设计模式:Reactor和Proactor对比
    到底什么时候该使用MQ?
    eclipse查看一个方法被谁引用(调用)的快捷键四种方式
    maven build pulgin
    VSCode 常用setiings.json设置
  • 原文地址:https://www.cnblogs.com/a1235202005/p/2680551.html
Copyright © 2011-2022 走看看