zoukankan      html  css  js  c++  java
  • WebFormAspNetPager用法(转载)

    1、增加用户控件的引用: 
    方法1:在<web>节点下添加上下列内容
    <pages validateRequest="false">
          <controls>
            <add tagPrefix="webdiyer" namespace="Wuqi.Webdiyer" assembly="AspNetPager"/>
          </controls>
    </pages>
    方法2:在前前台页面加入
    <%@ Register  TagPrefix ="webdiyer" Namespace ="Wuqi.Webdiyer" Assembly ="AspNetPager"  %>
    2、在页面上引用用户控件( 必须加入事件)
        <webdiyer:AspNetPager ID="AspNetPager1" runat="server" onpagechanged="AspNetPager1_PageChanged" >
     </webdiyer:AspNetPager>
    3、基本属性
         AspNetPager1.RecordCount = 100;//记录总数
         AspNetPager1.PageSize = 10;//每页显示的记录数
         AspNetPager1.CurrentPageIndex = 5;//当前页索引
    4、分页sql语句
    SELECT TOP 页大小 *  FROM 表 WHERE (ID NOT IN
    (SELECT TOP 页大小*(要访问的页-1) id FROM 表 ORDER BY id))
    ORDER BY ID
    5、必须事件//点击分页按钮时激发
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
       if (!IsPostBack)
            {
                AspNetPager1_PageChanged(new object(), new EventArgs());
            }

        //通用格式:
        protected void AspNetPager1_PageChanged(object sender, EventArgs e)//点击分页按钮时激发
        {
            string tables = "";//要查询的数据表:table
            string text = "";//要查询的字段:*
            string cd = "";//sql查询的条件 :type='你好'
            string px = "";//sql排序字段 :order by id
            AspNetPager1.PageSize = 10;//设置每页显示的记录
            AspNetPager1.RecordCount = sqldb.countRunProc("select count(id) from " + tables + " where  (" + cd + ") ");//记录总数
            string ye = (AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1)).ToString();  //要显示的页前面所有的记录
            string fenye = "select top " + AspNetPager1.PageSize + " " + text + " from " + tables + " where (id not in (select top " + ye + " id from " + tables + "  where (" + cd + ") " + px + ")) and  (" + cd + ") " + px + "";

            GridView1.DataSource = sqldb.dtRunProc(fenye);
            GridView1.DataBind();
    }

  • 相关阅读:
    贪心法
    div 样式
    echarts标题(title)配置
    利用svg画路径图 vue
    vue 杂项
    Charset 0x0408D00000/MS936 is not supported by the JVM
    Android开发中Eclipse常用快捷键
    Java 中强制删除文件的方法
    利用html5的localStorage结合jquery实现日常费用查询器
    Ant编译utf8非法字符:/65279 解决方法
  • 原文地址:https://www.cnblogs.com/zhwl/p/2016129.html
Copyright © 2011-2022 走看看