使用AspNetPager控件分页

简介: 页面后台写法 [csharp] view plaincopyprint? protected void Page_Load(object sender, EventArgs e)   {   if (!IsPos...

页面后台写法

  1. protected void Page_Load(object sender, EventArgs e)  
  2. {  
  3. if (!IsPostBack) { BindData(); }  
  4. }  
  5. protected void AspNetPager1_PageChanged(object sender, EventArgs e)  
  6. {  
  7. BindData();  
  8. }  
  9. public void BindData()  
  10. PageDataBaseOptater pdo = new PageDataBaseOptater();  
  11. AspNetPager1.RecordCount = pdo.GetRowCount("表名","where条件");  
  12. AspNetPager1.PageSize = pageSize;//pagesize可以设定  
  13. string cond = " where 条件";  
  14. DataSet ds = pdo.GetinfoList("表", AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, "记录的Id DESC", cond, "id名称"); Repeater1.DataSource = ds; Repeater1.DataBind(); 
  15.  
  16. dao层: 
  17.    public class PageDataBaseOptater 
  18.     { 
  19.        /// <summary> 
  20.        /// 获取记录数 
  21.         /// </summary> 
  22.         public int GetRowCount(string table,string where条件可以没有) 
  23.         { 
  24.            //获取表的记录总数             
  25.          } 
  26.         public DataSet GetinfoList(string table, int rowpage, int rowcount, 
  27.             string orderFid, string Conditions,string colum_id) 
  28.         { 
  29.             //sqlserver2005的 
  30.             //string query = "Select * From " 
  31.             //    + "(Select *,ROW_NUMBER() OVER(ORDER BY {2}) as RowNum From {4} {3}) as newTable " 
  32.             //    + "Where (RowNum BETWEEN ({0}) AND ({1}))"; 
  33.             //query = string.Format(query, (rowpage - 1) * rowcount , rowpage * rowcount, orderFid, Conditions, table); 
  34.             string query = "Select top {0} * From {1} {2} and {3}  not in(Select top {4} {3} From {1} {2} Order by {5}) Order by {5}"
  35.             query = string.Format(query, rowcount, table, Conditions, colum_id, (rowpage- 1) * rowcount, orderFid); 
  36.             DataDao dao = new DataDao(); 
  37.             return dao.PageGetDataSet(query); 
  38.         } 
  39.     } 
protected void Page_Load(object sender, EventArgs e) 
{ 
if (!IsPostBack) { BindData(); } 
} 
protected void AspNetPager1_PageChanged(object sender, EventArgs e) 
{ 
BindData(); 
} 
public void BindData() 
{
PageDataBaseOptater pdo = new PageDataBaseOptater(); 
AspNetPager1.RecordCount = pdo.GetRowCount("表名","where条件"); 
AspNetPager1.PageSize = pageSize;//pagesize可以设定 
string cond = " where 条件"; 
DataSet ds = pdo.GetinfoList("表", AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, "记录的Id DESC", cond, "id名称"); Repeater1.DataSource = ds; Repeater1.DataBind();
}

dao层:
   public class PageDataBaseOptater
    {
       /// <summary>
       /// 获取记录数
        /// </summary>
        public int GetRowCount(string table,string where条件可以没有)
        {
           //获取表的记录总数            
         }
        public DataSet GetinfoList(string table, int rowpage, int rowcount,
            string orderFid, string Conditions,string colum_id)
        {
            //sqlserver2005的
            //string query = "Select * From "
            //    + "(Select *,ROW_NUMBER() OVER(ORDER BY {2}) as RowNum From {4} {3}) as newTable "
            //    + "Where (RowNum BETWEEN ({0}) AND ({1}))";
            //query = string.Format(query, (rowpage - 1) * rowcount , rowpage * rowcount, orderFid, Conditions, table);
            string query = "Select top {0} * From {1} {2} and {3}  not in(Select top {4} {3} From {1} {2} Order by {5}) Order by {5}";
            query = string.Format(query, rowcount, table, Conditions, colum_id, (rowpage- 1) * rowcount, orderFid);
            DataDao dao = new DataDao();
            return dao.PageGetDataSet(query);
        }
    }

控件下载:http://download.csdn.net/detail/yysyangyangyangshan/3625510

目录
相关文章
|
Java Spring
11Spring - 基于AspectJ的AOP开发(注解的方式)
11Spring - 基于AspectJ的AOP开发(注解的方式)
117 0
|
缓存 网络协议 安全
【常见开源库的二次开发】HTTP之libcurl库——基础知识扫盲(一)
【常见开源库的二次开发】HTTP之libcurl库——基础知识扫盲(一)
657 1
|
人工智能 Apache
社区供稿 | 140B参数、可商用!OpenBuddy 发布首个开源千亿中文 MoE 模型的早期预览版
我们很自豪地于今天发布OpenBuddy最新一代千亿MoE大模型的早期预览版本:OpenBuddy-Mixtral-22Bx8-preview0-65k。此次发布的早期预览版对应约50%的训练进度。
|
机器学习/深度学习 数据采集 人工智能
NLP之文本分词综述
NLP之文本分词综述
902 0
|
Ubuntu 前端开发 Shell
Linux apt 命令
apt(Advanced Packaging Tool)是一个在 Debian 和 Ubuntu 中的 Shell 前端软件包管理器。 apt 命令提供了查找、安装、升级、删除某一个、一组甚至全部软件包的命令,而且命令简洁而又好记。 apt 命令执行需要超级管理员权限(root)。
402 2
|
存储 开发者
数字音频基础(中)| 学习笔记
快速学习数字音频基础(中),介绍了数字音频基础(中)系统机制, 以及在实际应用过程中如何使用。
数字音频基础(中)| 学习笔记
|
存储 缓存 移动开发
前端面试+学习笔记(HTML+CSS+JavaScript+ES6+Vue+NodeJs)
【面试大全】前端面试+学习笔记(HTML+CSS+JavaScript+ES6+Vue+NodeJs)
前端面试+学习笔记(HTML+CSS+JavaScript+ES6+Vue+NodeJs)
|
存储
Juc24_AQS的概述、体系架构、深入源码解读(非公平)、源码总结(五)
⑤. addWaiter(Node.EXCLUSIVE) ⑥. acquireQueued(addWaiter(Node.EXCLUSIVE), arg)
130 0
Juc24_AQS的概述、体系架构、深入源码解读(非公平)、源码总结(五)