.NET如何实现Repeater控件+AspNetPager控件分页
创始人
2024-11-28 17:03:20
0次

当然首先你要把bin文件放进你的项目,并加到你的工具栏去

//页头需引用的
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

控件部分(格式已经设计好)
9"
 LastPageText=":" NextPageText="8"
 PrevPageText="7" ShowCustomInfoSection="Left" InputBoxStyle="width:19px"
 TextAfterInputBox="页" TextBeforeInputBox="转到第" CustomInfoHTML="共检索到%RecordCount%条记录 页次:%CurrentPageIndex%/%PageCount% 每页%PageSize%条"
 HorizontalAlign="Right" Width="100%" ShowInputBox="Always" OnPageChanged="AspNetPager1_PageChanged"
 PageSize="20" ShowBoxThreshold="1">

后台绑定的代码

void databind()
    {
      int QYId = Convert.ToInt32(Request.Cookies["CompenyUser"].Value);//企业的Id
      DataTable dt = bll.Viewlist(QYId);
      this.AspNetPager1.RecordCount = dt.Rows.Count;//获取数据的总数

      PagedDataSource pds = new PagedDataSource();
      pds.DataSource = dt.DefaultView;//为控件绑定数据
      pds.AllowPaging = true;//分页启用
      pds.PageSize = AspNetPager1.PageSize;//获取每页显示的数量
      pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;

      Repeater1.DataSource = pds;
      Repeater1.DataBind();
    }

分页,只需要把绑定放在AspNetPager1_PageChanged 事件里

再给大家一个实例

前台页面代码

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TF_Product.aspx.cs" Inherits="TF_Product" %>
 

 
 
<%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %>
 


  通服产品
  
  
  $(document).ready(function()
  {
    //slides the element with class "menu_body" when paragraph with class "menu_head" is clicked
    $("#firstpane p.menu_head").click(function()
    {
      $(this).css({backgroundImage:"url(down.png)"}).next("div.menu_body").slideToggle(300).siblings("div.menu_body").slideUp("slow");
      $(this).siblings().css({backgroundImage:"url(left.png)"});
    });
  });
  

.menu_list { width: 229px; font-size:13px; }
.menu_head { padding: 8px 60px; cursor: pointer; position: relative; margin:1px; height:16px; background: #DFEDFA url(left.png) center right no-repeat; }
.menu_body { display:none;}
.menu_body a { display:block; color:#006699; background-color:#EFEFEF; padding-left:60px; padding-top:8px; padding-bottom:3px; text-decoration:none; }
.menu_body a:hover { color: #000000; text-decoration:underline; }







.anpager{background:#DFEDFA none repeat scroll 0 0;border:1px solid #CCCCCC;color:#FFFFFF;padding:4px 5px 4px 5px;}
.container, .container *{margin:0; padding:0;}
 
.container{width:886px; height:267px; overflow:hidden;position:relative;}
 
.slider{position:absolute;}
.slider li{ list-style:none;display:inline;}
.slider img{ width:886px; height:267px; display:block;}
 
.num{ position:absolute; right:5px; bottom:5px;}
.num li{
  float: left;
  color: #FF7300;
  text-align: center;
  line-height: 16px;
  width: 16px;
  height: 16px;
  font-family: Arial;
  font-size: 12px;
  cursor: pointer;
  overflow: hidden;
  margin: 3px 1px;
  border: 1px solid #FF7300;
  background-color: #fff;
}
.num li.on{
  color: #fff;
  line-height: 21px;
  width: 21px;
  height: 21px;
  font-size: 16px;
  margin: 0 1px;
  border: 0;
  background-color: #FF7300;
  font-weight: bold;
}







 
 
  
   
    
    
    
    【登陆】【注册】
    
    
    
   
  
 
 
  
首页   |
  新闻中心 |
  通服产品 |
  公司业绩 |
  服务中心 |
  解决方案 |
  关于我们 |
               
  •  
                          首页 > 通服产品        返回首页         
                   
           
                 基建产品

             普通基建美化基建     
        无源器件

              天线 负载      功分器 合路器      耦合器 双工器      AC安装配件 屏蔽器          防雷产品

              避雷器 防雷箱          电源产品

              开关电源 USP电源      远供电源 电源配套          IP通讯类产品

              IP网络产品 IP无线产品      IP安全产品 IP存储及服务器      IP多媒体产品 IP管理产品      H3C产品 迈普产品      迪普产品          工程辅材

              射频组件 电缆组件      光纤组件 五类缆组件      接地线 辅材包      套管 紧固件          连接器

              射频连接器 光纤连接器      转换头          服务类

              工程建设类 工程维护类      软件类          品牌分销

              华为产品          配件类

              配件类 标准件          其他

              邮费差额 工程类服务费用      折扣 设备                     产品类别:              关键字:                 
     
      
                                                                产品型号:      <%#Eval("pr_guige")%>查看详情                         产品编码:      <%#Eval("pr_bianma")%>                         产品描述:      <%#Eval("pr_ms")%>                         
                                                           

    后台代码

    Tb_productsHelper helper = new Tb_productsHelper();
        IList list = helper.GetAllListBySql(product_sql);
        this.AspNetPager1.RecordCount = list.Count;//绑定总数量
        this.AspNetPager1.AlwaysShow = true;
        //先声明一个分页类对象
        PagedDataSource ps = new PagedDataSource();
        ps.AllowPaging = true;
        ps.PageSize = this.AspNetPager1.PageSize;
        ps.CurrentPageIndex = this.AspNetPager1.CurrentPageIndex-1;
        ps.DataSource = list;
        this.rp.DataSource = ps;
        this.rp.DataBind();

    相关内容

    热门资讯

    空调连续工作多久需要停机休息 空调连续工作的时间取决于多个因素,包括空调的型号、功率、使用环境和维护情况等。一般来说,空调可以连续...
    空调哪个符号是除湿的 空调除湿功能通常用一个水滴形状的符号表示。不同品牌和型号的空调遥控器可能会有所差异,但一般来说,除湿...
    格力空调多长时间加一次氟利昂 1、一般情况下,空调对氟利昂的使用量是非常小的,所以在空调使用了四年左右的时候再考虑加也没问题。2、...
    空调用多长时间需要加氟一次 一般情况下是五年。当出现以下这几种情况时,空调才需要加氟。1、空调的室内机和室外机各有两个接口,当接...
    格调生活·C标思享荟:卡萨帝在... 9月12日的郑州龙湖金融岛,夜风轻拂,灯光璀璨。“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑...
    品牌价值破千亿、高端份额持续领... 9月12日,“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑州站”在郑州龙湖金融岛举办。2026...
    空调主板坏了修800还是换新的 空调主板坏了是修还是换新,需要考虑多个因素,以下是一些建议:1. 维修成本:如果维修费用较低,比如 ...
    空调开多久需要休息多长时间 问题:空调开多久需要休息多长时间回答:1、在使用空调的过程中,一般空调开7~8个小时左右需要休息2~...
    中央空调多长时间清洗一次 1、一般空调开机前清洗一次即可,空调开机中间时段再清洗一次,空调关机时清洗一次,这样比较合理。2、空...
    中央空调氟利昂多久加一次 看空调制热和制冷程度,很多人的观点认为氟利昂必须一年放一次,其实这个观点是错误的,理解上面有点偏差,...