首页 后端开发 C#.Net教程 .NET实现Repeater控件+AspNetPager控件分页

.NET实现Repeater控件+AspNetPager控件分页

Feb 08, 2017 am 09:20 AM

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

//页头需引用的
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
 
控件部分(格式已经设计好)
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" AlwaysShow="True" FirstPageText="<font face=&#39;Webdings&#39;>9</font>"
 LastPageText="<font face=&#39;Webdings&#39;>:</font>" NextPageText="<font face=&#39;Webdings&#39;>8</font>"
 PrevPageText="<font face=&#39;Webdings&#39;>7</font>" ShowCustomInfoSection="Left" InputBoxStyle="width:19px"
 TextAfterInputBox="页" TextBeforeInputBox="转到第" CustomInfoHTML="共检索到<strong>%RecordCount%</strong>条记录 页次:<strong>%CurrentPageIndex%/%PageCount%</strong> 每页<strong>%PageSize%</strong>条"
 HorizontalAlign="Right" Width="100%" ShowInputBox="Always" OnPageChanged="AspNetPager1_PageChanged"
 PageSize="20" ShowBoxThreshold="1">
</webdiyer:AspNetPager>
登录后复制

后台绑定的代码

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" %>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  
  
<%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %>
  
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>通服产品</title>
  <script src="jquery.js" type="text/javascript"></script>
  <script type="text/javascript">
  $(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)"});
    });
  });
  </script>
<style type="text/css">
.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; }
</style>
<meta name="keywords" content="通服科技">
<meta name="description" content="江西通服科技有限公司">
<link href="./Index_files/style.css" type="text/css" rel="stylesheet">
<script src="js/AC_RunActiveContent.js" type="text/javascript"></script>
<!--焦点图-->
<style type="text/css">
.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;
}
</style>
<!--焦点图-->
</head>
<body>
<form runat="server">
<!--头部-->
<table width="878" height="114" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#FFFFFF">
 <tbody>
 <tr>
  <td height="77">
   <table width="878px" border="0" cellpadding="0" cellspacing="0">
    <tbody>
    <tr><td width="73%" height="53" rowspan="2" align="left"><img src="./Index_files/LOGO_SY180-60.png" width="178" height="60" border="0"></td>
    <td width="27%" align="right" valign="top">
    【登陆】【注册】
    </td>
    </tr>
    </tbody>
   </table>
  </td>
 </tr>
 <tr>
  <td width="878" align="center" style=" border-bottom:1px solid blue;" ><div style="width:100px; float:left;"></div>
<div id="nav" align="center">
<a href="Default.aspx" target="_self" style="color:Black;">首页   |</a></div>
  
<div id="nav" align="center">
<a href="TF_RecList.aspx" target="_self" style="color:Black;">新闻中心 |</a></div>
  
<div id="nav" align="center">
<a href="TF_Product.aspx" target="_self" style="color:Black;">通服产品 |</a></div>
  
<div id="nav" align="center">
<a href="TF_Objects.aspx" target="_self" style="color:Black;">公司业绩 |</a></div>
  
<div id="nav" align="center">
<a href="TF_Servers.aspx" target="_self" style="color:Black;">服务中心 |</a></div>
  
<div id="nav" align="center">
<a href="TF_Solution.aspx" target="_self" style="color:Black;">解决方案 |</a></div>
  
<div id="nav" align="center">
<a href="AboutUs.aspx" target="_self" style="color:Black;">关于我们 |</a></div>
</td>
 </tr>
 <tr>
  <td align="center" width="878px">
   <div class="container" id="idTransformView">
 <ul class="slider" id="idSlider">
  <li><img src="images/01.jpg"/></li>
 </ul>
</div>
  </td>
 </tr>
</tbody>
</table>
<!--中间-->
<table width="890" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#FFFFFF">
 <tbody>
 <tr>
 <td>
  <div style="border:1px solid #DFEDFA; height:26px; padding-top:5px; padding-left:1%">
  <table width="100%">
  <tr>
  <td>首页 > 通服产品</td>
  <td> </td><td> </td>
  <td align="right"><a href="Default.aspx">返回首页</a></td>
  </tr>
  </table>
  </div>
 </td>
 </tr>
 </tbody>
</table>
<table width="890" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#FFFFFF">
 <tbody>
 <tr>
  <td width="229" valign="top">
  <div>
    <img src="img/20140305165205.jpg" width="229px" />
  </div>
   <div id="firstpane" class="menu_list">
    <!--Code for menu starts here-->
    <p class="menu_head">基建产品</p>
    <div class="menu_body">
    <a href="TF_Product.aspx?id=45">普通基建</a><a href="TF_Product.aspx?id=46">美化基建</a>
    </div>
    <p class="menu_head">无源器件</p>
    <div class="menu_body">
     <a href="TF_Product.aspx?id=5">天线</a> <a href="TF_Product.aspx?id=14">负载</a>
     <a href="TF_Product.aspx?id=11">功分器</a> <a href="TF_Product.aspx?id=17">合路器</a>
     <a href="TF_Product.aspx?id=47">耦合器</a> <a href="TF_Product.aspx?id=56">双工器</a>
     <a href="TF_Product.aspx?id=70">AC安装配件</a> <a href="TF_Product.aspx?id=89">屏蔽器</a>
    </div>
    <p class="menu_head">防雷产品</p>
    <div class="menu_body">
     <a href="TF_Product.aspx?id=10">避雷器</a> <a href="TF_Product.aspx?id=57">防雷箱</a>
    </div>
    <p class="menu_head">电源产品</p>
    <div class="menu_body">
     <a href="TF_Product.aspx?id=12">开关电源</a> <a href="TF_Product.aspx?id=23">USP电源</a>
     <a href="TF_Product.aspx?id=61">远供电源</a> <a href="TF_Product.aspx?id=81">电源配套</a>
    </div>
    <p class="menu_head">IP通讯类产品</p>
    <div class="menu_body">
     <a href="TF_Product.aspx?id=27">IP网络产品</a> <a href="TF_Product.aspx?id=29">IP无线产品</a>
     <a href="TF_Product.aspx?id=30">IP安全产品</a> <a href="TF_Product.aspx?id=31">IP存储及服务器</a>
     <a href="TF_Product.aspx?id=32">IP多媒体产品</a> <a href="TF_Product.aspx?id=33">IP管理产品</a>
     <a href="TF_Product.aspx?id=71">H3C产品</a> <a href="TF_Product.aspx?id=72">迈普产品</a>
     <a href="TF_Product.aspx?id=73">迪普产品</a>
    </div>
    <p class="menu_head">工程辅材</p>
    <div class="menu_body">
     <a href="TF_Product.aspx?id=6">射频组件</a> <a href="TF_Product.aspx?id=7">电缆组件</a>
     <a href="TF_Product.aspx?id=8">光纤组件</a> <a href="TF_Product.aspx?id=9">五类缆组件</a>
     <a href="TF_Product.aspx?id=18">接地线</a> <a href="TF_Product.aspx?id=62">辅材包</a>
     <a href="TF_Product.aspx?id=82">套管</a> <a href="TF_Product.aspx?id=83">紧固件</a>
    </div>
    <p class="menu_head">连接器</p>
    <div class="menu_body">
     <a href="TF_Product.aspx?id=15">射频连接器</a> <a href="TF_Product.aspx?id=16">光纤连接器</a>
     <a href="TF_Product.aspx?id=63">转换头</a>
    </div>
    <p class="menu_head">服务类</p>
    <div class="menu_body">
     <a href="TF_Product.aspx?id=58">工程建设类</a> <a href="TF_Product.aspx?id=59">工程维护类</a>
     <a href="TF_Product.aspx?id=60">软件类</a>
    </div>
    <p class="menu_head">品牌分销</p>
    <div class="menu_body">
     <a href="TF_Product.aspx?id=87">华为产品</a>
    </div>
    <p class="menu_head">配件类</p>
    <div class="menu_body">
     <a href="TF_Product.aspx?id=67">配件类</a> <a href="TF_Product.aspx?id=86">标准件</a>
    </div>
    <p class="menu_head">其他</p>
    <div class="menu_body">
     <a href="TF_Product.aspx?id=66">邮费差额</a> <a href="TF_Product.aspx?id=69">工程类服务费用</a>
     <a href="TF_Product.aspx?id=78">折扣</a> <a href="TF_Product.aspx?id=88">设备</a>
    </div>
   </div>
  </td>
  <td width="660" valign="top">
  <div style="border-bottom:1px solid #DFEDFA; padding-left:2%; margin-left:2%;">
  产品类别:<asp:DropDownList ID="ddlProductType" runat="server" DataTextField="pt_name" DataValueField="pt_id">
     </asp:DropDownList>
     
  关键字:<asp:TextBox ID="txtGJZ" runat="server"></asp:TextBox>
     
     <asp:Button ID="btnSel" runat="server" Text="搜索" onclick="btnSel_Click" />
  </div>
  <div> </div>
  <div>
    <asp:Repeater ID="rp" runat="server">
    <ItemTemplate>
     <div style="margin-left:2%; border:1px solid #DFEDFA; padding:3px; margin-top:2px; margin-bottom:3px;">
     <table width="100%">
     <tr height="24px">
     <td rowspan="4" width="90px">
       <asp:Image ID="Image1" ImageUrl="~/Product_pic/NoPic.jpg" runat="server" Width="90px" Height="90px" />
     </td>
     <td width="9px"> </td>
     <td width="60px">产品型号:</td>
     <td><span style="float:left"><%#Eval("pr_guige")%></span><span style="float:right;"><a href="#">查看详情</a></span></td>
     </tr>
     <tr height="24px">
     <td width="9px"> </td>
     <td>产品编码:</td>
     <td><%#Eval("pr_bianma")%></td>
     </tr>
     <tr height="30px">
     <td width="9px"> </td>
     <td>产品描述:</td>
     <td><%#Eval("pr_ms")%></td>
     </tr>
     <tr><td height="8px"> </td></tr>
     </table>
     </div>
    </ItemTemplate>
    </asp:Repeater>
    <div style="height:22px; margin-left:2%;" align="right">
    <webdiyer:AspNetPager ID="AspNetPager1" CssClass="anpager" runat="server" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页"
        onpagechanged="AspNetPager1_PageChanged" PageSize="6" ShowMoreButtons="False" ShowPageIndexBox="Never">
      </webdiyer:AspNetPager>
  </div>
  </div>
    
  </td>
 </tr>
</tbody>
</table>
<!--版权声明-->
<table width="878" border="0" align="center">
 <tbody>
 <tr>
 <td>
 <img src="./Index_files/foot_02.gif" usemap="#foot" width="878">
 </td>
 </tr>
 </tbody>
</table>
</form>
</body>
</html>
登录后复制

后台代码

Tb_productsHelper helper = new Tb_productsHelper();
    IList<Tb_productsInfo> 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();
登录后复制

更多.NET实现Repeater控件+AspNetPager控件分页相关文章请关注PHP中文网!

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

char在C语言字符串中的作用是什么 char在C语言字符串中的作用是什么 Apr 03, 2025 pm 03:15 PM

在 C 语言中,char 类型在字符串中用于:1. 存储单个字符;2. 使用数组表示字符串并以 null 终止符结束;3. 通过字符串操作函数进行操作;4. 从键盘读取或输出字符串。

char在C语言中如何处理特殊字符 char在C语言中如何处理特殊字符 Apr 03, 2025 pm 03:18 PM

C语言中通过转义序列处理特殊字符,如:\n表示换行符。\t表示制表符。使用转义序列或字符常量表示特殊字符,如char c = '\n'。注意,反斜杠需要转义两次。不同平台和编译器可能有不同的转义序列,请查阅文档。

C语言各种符号的使用方法 C语言各种符号的使用方法 Apr 03, 2025 pm 04:48 PM

C 语言中符号的使用方法涵盖算术、赋值、条件、逻辑、位运算符等。算术运算符用于基本数学运算,赋值运算符用于赋值和加减乘除赋值,条件运算符用于根据条件执行不同操作,逻辑运算符用于逻辑操作,位运算符用于位级操作,特殊常量用于表示空指针、文件结束标记和非数字值。

char与wchar_t在C语言中的区别 char与wchar_t在C语言中的区别 Apr 03, 2025 pm 03:09 PM

在 C 语言中,char 和 wchar_t 的主要区别在于字符编码:char 使用 ASCII 或扩展 ASCII,wchar_t 使用 Unicode;char 占用 1-2 个字节,wchar_t 占用 2-4 个字节;char 适用于英语文本,wchar_t 适用于多语言文本;char 广泛支持,wchar_t 依赖于编译器和操作系统是否支持 Unicode;char 的字符范围受限,wchar_t 的字符范围更大,并使用专门的函数进行算术运算。

c#多线程和异步的区别 c#多线程和异步的区别 Apr 03, 2025 pm 02:57 PM

多线程和异步的区别在于,多线程同时执行多个线程,而异步在不阻塞当前线程的情况下执行操作。多线程用于计算密集型任务,而异步用于用户交互操作。多线程的优势是提高计算性能,异步的优势是不阻塞 UI 线程。选择多线程还是异步取决于任务性质:计算密集型任务使用多线程,与外部资源交互且需要保持 UI 响应的任务使用异步。

char在C语言中如何进行类型转换 char在C语言中如何进行类型转换 Apr 03, 2025 pm 03:21 PM

在 C 语言中,char 类型转换可以通过:强制类型转换:使用强制类型转换符将一种类型的数据直接转换为另一种类型。自动类型转换:当一种类型的数据可以容纳另一种类型的值时,编译器自动进行转换。

C语言 sum 的作用是什么? C语言 sum 的作用是什么? Apr 03, 2025 pm 02:21 PM

C语言中没有内置求和函数,需自行编写。可通过遍历数组并累加元素实现求和:循环版本:使用for循环和数组长度计算求和。指针版本:使用指针指向数组元素,通过自增指针遍历高效求和。动态分配数组版本:动态分配数组并自行管理内存,确保释放已分配内存以防止内存泄漏。

char数组在C语言中如何使用 char数组在C语言中如何使用 Apr 03, 2025 pm 03:24 PM

char 数组在 C 语言中存储字符序列,声明为 char array_name[size]。访问元素通过下标运算符,元素以空终止符 '\0' 结尾,用于表示字符串终点。C 语言提供多种字符串操作函数,如 strlen()、strcpy()、strcat() 和 strcmp()。

See all articles