zoukankan      html  css  js  c++  java
  • 使用AspNetPager高效分页..

    第三方控件下载地址:http://www.webdiyer.com/Controls/AspNetPager/Downloads

    实现最基本的高效分页 需要两个存储过程,第一个是获取全部数据数量的SQL,第二个是分页用的SQL语句了

     先上SQL代码:分页用的存储过程 

    CREATE PROCEDURE Proc_GridView_Pager
        
    @startIndex int,
        
    @endIndex int
    AS
    BEGIN
        
    select * from (
        
    select a.id,a.saleName,a.price,a.count,a.amount,b.Name,a.inDate,row_number()over(order by a.inDate desc)rownum
        
    from InBill a
        
    inner join InBillType b
        
    on a.InTypeId = b.id
    ) t
    where t.rownum >=@startIndex and t.rownum<=@endIndex;
    END

     GO 


    获取数据总数量的存储过程


     CREATE PROCEDURE Proc_GetAllData_Count

     AS
     

    BEGIN

    selectcount(*from inbill

     END

    GO 

    然后给aspnetPager添加PageChanged 事件代码如下:这个是分页用的代码

    string commandText = "Proc_GridView_Pager";
                gvInBillList.DataSource 
    = SQLHelper.GetDateSet(commandText, CommandType.StoredProcedure,
                new SqlParameter("
    @startIndex", anpGridView.StartRecordIndex),
                new SqlParameter("
    @endIndex", anpGridView.EndRecordIndex));

                gvInBillList.DataBind(); 

       

    最后一步了,就是上面提到的获取全部数据的存储过程,就是在这个时候用了,当页面加载的时候调用方法

     anpGridView.RecordCount = new InBillManager().GetAllDataCount();

  • 相关阅读:
    debian7安装oracle11g
    unix fopen和fopen_s用法的比较
    QT的三种协议说明
    Qt之遍历文件夹
    Debian 7 安装配置总结
    用户不在sudoers文件中的解决方法 .
    QT断点续传
    QFtp类参考
    FTP服务器简易有效的访问方法
    Java爬虫搜索原理实现
  • 原文地址:https://www.cnblogs.com/zhuiyi/p/2049936.html
Copyright © 2011-2022 走看看