search
HomeBackend DevelopmentC#.Net Tutorial.NET implements Repeater control + AspNetPager control paging

Of course first you have to put the bin file into your project and add it to your toolbar

//页头需引用的
<%@ 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>

Background binding code

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();
    }

Paging, just put the binding in the AspNetPager1_PageChanged event

Let me give you another example

Foreground page code

<%@ 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="/static/imghwm/default1.png"  data-src="./Index_files/LOGO_SY180-60.png"  class="lazy"      style="max-width:90%"  style="max-width:90%" border="0" alt=".NET implements Repeater control + AspNetPager control paging" ></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="/static/imghwm/default1.png"  data-src="images/01.jpg"  class="lazy"  / alt=".NET implements Repeater control + AspNetPager control paging" ></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="/static/imghwm/default1.png"  data-src="img/20140305165205.jpg"  class="lazy"      style="max-width:90%" / alt=".NET implements Repeater control + AspNetPager control paging" >
  </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="/static/imghwm/default1.png"  data-src="./Index_files/foot_02.gif"  class="lazy"   usemap="#foot"    style="max-width:90%" alt=".NET implements Repeater control + AspNetPager control paging" >
 </td>
 </tr>
 </tbody>
</table>
</form>
</body>
</html>

Backend code

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();

For more .NET implementation of Repeater control + AspNetPager control paging related articles, please pay attention to the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
C# and .NET: Understanding the Relationship Between the TwoC# and .NET: Understanding the Relationship Between the TwoApr 17, 2025 am 12:07 AM

The relationship between C# and .NET is inseparable, but they are not the same thing. C# is a programming language, while .NET is a development platform. C# is used to write code, compile into .NET's intermediate language (IL), and executed by the .NET runtime (CLR).

The Continued Relevance of C# .NET: A Look at Current UsageThe Continued Relevance of C# .NET: A Look at Current UsageApr 16, 2025 am 12:07 AM

C#.NET is still important because it provides powerful tools and libraries that support multiple application development. 1) C# combines .NET framework to make development efficient and convenient. 2) C#'s type safety and garbage collection mechanism enhance its advantages. 3) .NET provides a cross-platform running environment and rich APIs, improving development flexibility.

From Web to Desktop: The Versatility of C# .NETFrom Web to Desktop: The Versatility of C# .NETApr 15, 2025 am 12:07 AM

C#.NETisversatileforbothwebanddesktopdevelopment.1)Forweb,useASP.NETfordynamicapplications.2)Fordesktop,employWindowsFormsorWPFforrichinterfaces.3)UseXamarinforcross-platformdevelopment,enablingcodesharingacrossWindows,macOS,Linux,andmobiledevices.

C# .NET and the Future: Adapting to New TechnologiesC# .NET and the Future: Adapting to New TechnologiesApr 14, 2025 am 12:06 AM

C# and .NET adapt to the needs of emerging technologies through continuous updates and optimizations. 1) C# 9.0 and .NET5 introduce record type and performance optimization. 2) .NETCore enhances cloud native and containerized support. 3) ASP.NETCore integrates with modern web technologies. 4) ML.NET supports machine learning and artificial intelligence. 5) Asynchronous programming and best practices improve performance.

Is C# .NET Right for You? Evaluating its ApplicabilityIs C# .NET Right for You? Evaluating its ApplicabilityApr 13, 2025 am 12:03 AM

C#.NETissuitableforenterprise-levelapplicationswithintheMicrosoftecosystemduetoitsstrongtyping,richlibraries,androbustperformance.However,itmaynotbeidealforcross-platformdevelopmentorwhenrawspeediscritical,wherelanguageslikeRustorGomightbepreferable.

C# Code within .NET: Exploring the Programming ProcessC# Code within .NET: Exploring the Programming ProcessApr 12, 2025 am 12:02 AM

The programming process of C# in .NET includes the following steps: 1) writing C# code, 2) compiling into an intermediate language (IL), and 3) executing by the .NET runtime (CLR). The advantages of C# in .NET are its modern syntax, powerful type system and tight integration with the .NET framework, suitable for various development scenarios from desktop applications to web services.

C# .NET: Exploring Core Concepts and Programming FundamentalsC# .NET: Exploring Core Concepts and Programming FundamentalsApr 10, 2025 am 09:32 AM

C# is a modern, object-oriented programming language developed by Microsoft and as part of the .NET framework. 1.C# supports object-oriented programming (OOP), including encapsulation, inheritance and polymorphism. 2. Asynchronous programming in C# is implemented through async and await keywords to improve application responsiveness. 3. Use LINQ to process data collections concisely. 4. Common errors include null reference exceptions and index out-of-range exceptions. Debugging skills include using a debugger and exception handling. 5. Performance optimization includes using StringBuilder and avoiding unnecessary packing and unboxing.

Testing C# .NET Applications: Unit, Integration, and End-to-End TestingTesting C# .NET Applications: Unit, Integration, and End-to-End TestingApr 09, 2025 am 12:04 AM

Testing strategies for C#.NET applications include unit testing, integration testing, and end-to-end testing. 1. Unit testing ensures that the minimum unit of the code works independently, using the MSTest, NUnit or xUnit framework. 2. Integrated tests verify the functions of multiple units combined, commonly used simulated data and external services. 3. End-to-end testing simulates the user's complete operation process, and Selenium is usually used for automated testing.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool