麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > .NET > 正文

.NET實現Repeater控件+AspNetPager控件分頁

2024-07-10 13:29:40
字體:
來源:轉載
供稿:網友

本文給大家分享的2個示例,演示AspNetPager最基本的功能,幫助您認識AspNetPager分頁控件及了解它的工作原理。有需要的小伙伴可以參考下

當然首先你要把bin文件放進你的項目,并加到你的工具欄去

 

 
  1. //頁頭需引用的 
  2. <%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %> 
  3.  
  4. 控件部分(格式已經設計好) 
  5. <webdiyer:AspNetPager ID="AspNetPager1" runat="server" AlwaysShow="True" FirstPageText="<font face='Webdings'>9</font>" 
  6. LastPageText="<font face='Webdings'>:</font>" NextPageText="<font face='Webdings'>8</font>" 
  7. PrevPageText="<font face='Webdings'>7</font>" ShowCustomInfoSection="Left" InputBoxStyle="width:19px" 
  8. TextAfterInputBox="頁" TextBeforeInputBox="轉到第" CustomInfoHTML="共檢索到<strong>%RecordCount%</strong>條記錄 頁次:<strong>%CurrentPageIndex%/%PageCount%</strong> 每頁<strong>%PageSize%</strong>條" 
  9. HorizontalAlign="Right" Width="100%" ShowInputBox="Always" OnPageChanged="AspNetPager1_PageChanged" 
  10. PageSize="20" ShowBoxThreshold="1"
  11. </webdiyer:AspNetPager> 

后臺綁定的代碼

 

 
  1. void databind() 
  2. int QYId = Convert.ToInt32(Request.Cookies["CompenyUser"].Value);//企業的Id 
  3. DataTable dt = bll.Viewlist(QYId); 
  4. this.AspNetPager1.RecordCount = dt.Rows.Count;//獲取數據的總數 
  5.  
  6. PagedDataSource pds = new PagedDataSource(); 
  7. pds.DataSource = dt.DefaultView;//為控件綁定數據 
  8. pds.AllowPaging = true;//分頁啟用 
  9. pds.PageSize = AspNetPager1.PageSize;//獲取每頁顯示的數量 
  10. pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; 
  11.  
  12. Repeater1.DataSource = pds; 
  13. Repeater1.DataBind(); 

分頁,只需要把綁定放在AspNetPager1_PageChanged 事件里

再給大家一個實例

前臺頁面代碼

 

 
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TF_Product.aspx.cs" Inherits="TF_Product" %> 
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
  4.  
  5.  
  6. <%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %> 
  7.  
  8. <html xmlns="http://www.w3.org/1999/xhtml"
  9. <head runat="server"
  10. <title>通服產品</title> 
  11. <script src="jquery.js" type="text/javascript"></script> 
  12. <script type="text/javascript"
  13. $(document).ready(function() 
  14. //slides the element with class "menu_body" when paragraph with class "menu_head" is clicked 
  15. $("#firstpane p.menu_head").click(function() 
  16. $(this).css({backgroundImage:"url(down.png)"}).next("div.menu_body").slideToggle(300).siblings("div.menu_body").slideUp("slow"); 
  17. $(this).siblings().css({backgroundImage:"url(left.png)"}); 
  18. }); 
  19. }); 
  20. </script> 
  21. <style type="text/css"
  22. .menu_list { width: 229px; font-size:13px; } 
  23. .menu_head { padding: 8px 60px; cursor: pointer; position: relative; margin:1px; height:16px; background: #DFEDFA url(left.png) center right no-repeat; } 
  24. .menu_body { display:none;} 
  25. .menu_body a { display:block; color:#006699; background-color:#EFEFEF; padding-left:60px; padding-top:8px; padding-bottom:3px; text-decoration:none; } 
  26. .menu_body a:hover { color: #000000; text-decoration:underline; } 
  27. </style> 
  28. <meta name="keywords" content="通服科技"
  29. <meta name="description" content="江西通服科技有限公司"
  30. <link href="./Index_files/style.css" type="text/css" rel="stylesheet"
  31. <script src="js/AC_RunActiveContent.js" type="text/javascript"></script> 
  32. <!--焦點圖--> 
  33. <style type="text/css"
  34. .anpager{background:#DFEDFA none repeat scroll 0 0;border:1px solid #CCCCCC;color:#FFFFFF;padding:4px 5px 4px 5px;} 
  35. .container, .container *{margin:0; padding:0;} 
  36.  
  37. .container{width:886px; height:267px; overflow:hidden;position:relative;} 
  38.  
  39. .slider{position:absolute;} 
  40. .slider li{ list-style:none;display:inline;} 
  41. .slider img{ width:886px; height:267px; display:block;} 
  42.  
  43. .num{ position:absolute; right:5px; bottom:5px;} 
  44. .num li{ 
  45. float: left; 
  46. color: #FF7300; 
  47. text-align: center; 
  48. line-height: 16px; 
  49. width: 16px; 
  50. height: 16px; 
  51. font-family: Arial; 
  52. font-size: 12px; 
  53. cursor: pointer; 
  54. overflow: hidden; 
  55. margin: 3px 1px; 
  56. border: 1px solid #FF7300; 
  57. background-color: #fff; 
  58. .num li.on{ 
  59. color: #fff; 
  60. line-height: 21px; 
  61. width: 21px; 
  62. height: 21px; 
  63. font-size: 16px; 
  64. margin: 0 1px; 
  65. border: 0; 
  66. background-color: #FF7300; 
  67. font-weight: bold; 
  68. </style> 
  69. <!--焦點圖--> 
  70. </head> 
  71. <body> 
  72. <form runat="server"
  73. <!--頭部--> 
  74. <table width="878" height="114" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#FFFFFF"
  75. <tbody> 
  76. <tr> 
  77. <td height="77"
  78. <table width="878px" border="0" cellpadding="0" cellspacing="0"
  79. <tbody> 
  80. <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> 
  81. <td width="27%" align="right" valign="top"
  82. 【登陸】【注冊】 
  83. </td> 
  84. </tr> 
  85. </tbody> 
  86. </table> 
  87. </td> 
  88. </tr> 
  89. <tr> 
  90. <td width="878" align="center" style=" border-bottom:1px solid blue;" ><div style="width:100px; float:left;"></div> 
  91. <div id="nav" align="center"
  92. <a href="Default.aspx" target="_self" style="color:Black;">首頁 |</a></div> 
  93.  
  94. <div id="nav" align="center"
  95. <a href="TF_RecList.aspx" target="_self" style="color:Black;">新聞中心 |</a></div> 
  96.  
  97. <div id="nav" align="center"
  98. <a href="TF_Product.aspx" target="_self" style="color:Black;">通服產品 |</a></div> 
  99.  
  100. <div id="nav" align="center"
  101. <a href="TF_Objects.aspx" target="_self" style="color:Black;">公司業績 |</a></div> 
  102.  
  103. <div id="nav" align="center"
  104. <a href="TF_Servers.aspx" target="_self" style="color:Black;">服務中心 |</a></div> 
  105.  
  106. <div id="nav" align="center"
  107. <a href="TF_Solution.aspx" target="_self" style="color:Black;">解決方案 |</a></div> 
  108.  
  109. <div id="nav" align="center"
  110. <a href="AboutUs.aspx" target="_self" style="color:Black;">關于我們 |</a></div> 
  111. </td> 
  112. </tr> 
  113. <tr> 
  114. <td align="center" width="878px"
  115. <div class="container" id="idTransformView"
  116. <ul class="slider" id="idSlider"
  117. <li><img src="images/01.jpg"/></li> 
  118. </ul> 
  119. </div> 
  120. </td> 
  121. </tr> 
  122. </tbody> 
  123. </table> 
  124. <!--中間--> 
  125. <table width="890" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#FFFFFF"
  126. <tbody> 
  127. <tr> 
  128. <td> 
  129. <div style="border:1px solid #DFEDFA; height:26px; padding-top:5px; padding-left:1%"
  130. <table width="100%"
  131. <tr> 
  132. <td>首頁 > 通服產品</td> 
  133. <td> </td><td> </td> 
  134. <td align="right"><a href="Default.aspx">返回首頁</a></td> 
  135. </tr> 
  136. </table> 
  137. </div> 
  138. </td> 
  139. </tr> 
  140. </tbody> 
  141. </table> 
  142. <table width="890" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#FFFFFF"
  143. <tbody> 
  144. <tr> 
  145. <td width="229" valign="top"
  146. <div> 
  147. <img src="img/20140305165205.jpg" width="229px" /> 
  148. </div> 
  149. <div id="firstpane" class="menu_list"
  150. <!--Code for menu starts here--> 
  151. <p class="menu_head">基建產品</p> 
  152. <div class="menu_body"
  153. <a href="TF_Product.aspx?id=45">普通基建</a><a href="TF_Product.aspx?id=46">美化基建</a> 
  154. </div> 
  155. <p class="menu_head">無源器件</p> 
  156. <div class="menu_body"
  157. <a href="TF_Product.aspx?id=5">天線</a> <a href="TF_Product.aspx?id=14">負載</a> 
  158. <a href="TF_Product.aspx?id=11">功分器</a> <a href="TF_Product.aspx?id=17">合路器</a> 
  159. <a href="TF_Product.aspx?id=47">耦合器</a> <a href="TF_Product.aspx?id=56">雙工器</a> 
  160. <a href="TF_Product.aspx?id=70">AC安裝配件</a> <a href="TF_Product.aspx?id=89">屏蔽器</a> 
  161. </div> 
  162. <p class="menu_head">防雷產品</p> 
  163. <div class="menu_body"
  164. <a href="TF_Product.aspx?id=10">避雷器</a> <a href="TF_Product.aspx?id=57">防雷箱</a> 
  165. </div> 
  166. <p class="menu_head">電源產品</p> 
  167. <div class="menu_body"
  168. <a href="TF_Product.aspx?id=12">開關電源</a> <a href="TF_Product.aspx?id=23">USP電源</a> 
  169. <a href="TF_Product.aspx?id=61">遠供電源</a> <a href="TF_Product.aspx?id=81">電源配套</a> 
  170. </div> 
  171. <p class="menu_head">IP通訊類產品</p> 
  172. <div class="menu_body"
  173. <a href="TF_Product.aspx?id=27">IP網絡產品</a> <a href="TF_Product.aspx?id=29">IP無線產品</a> 
  174. <a href="TF_Product.aspx?id=30">IP安全產品</a> <a href="TF_Product.aspx?id=31">IP存儲及服務器</a> 
  175. <a href="TF_Product.aspx?id=32">IP多媒體產品</a> <a href="TF_Product.aspx?id=33">IP管理產品</a> 
  176. <a href="TF_Product.aspx?id=71">H3C產品</a> <a href="TF_Product.aspx?id=72">邁普產品</a> 
  177. <a href="TF_Product.aspx?id=73">迪普產品</a> 
  178. </div> 
  179. <p class="menu_head">工程輔材</p> 
  180. <div class="menu_body"
  181. <a href="TF_Product.aspx?id=6">射頻組件</a> <a href="TF_Product.aspx?id=7">電纜組件</a> 
  182. <a href="TF_Product.aspx?id=8">光纖組件</a> <a href="TF_Product.aspx?id=9">五類纜組件</a> 
  183. <a href="TF_Product.aspx?id=18">接地線</a> <a href="TF_Product.aspx?id=62">輔材包</a> 
  184. <a href="TF_Product.aspx?id=82">套管</a> <a href="TF_Product.aspx?id=83">緊固件</a> 
  185. </div> 
  186. <p class="menu_head">連接器</p> 
  187. <div class="menu_body"
  188. <a href="TF_Product.aspx?id=15">射頻連接器</a> <a href="TF_Product.aspx?id=16">光纖連接器</a> 
  189. <a href="TF_Product.aspx?id=63">轉換頭</a> 
  190. </div> 
  191. <p class="menu_head">服務類</p> 
  192. <div class="menu_body"
  193. <a href="TF_Product.aspx?id=58">工程建設類</a> <a href="TF_Product.aspx?id=59">工程維護類</a> 
  194. <a href="TF_Product.aspx?id=60">軟件類</a> 
  195. </div> 
  196. <p class="menu_head">品牌分銷</p> 
  197. <div class="menu_body"
  198. <a href="TF_Product.aspx?id=87">華為產品</a> 
  199. </div> 
  200. <p class="menu_head">配件類</p> 
  201. <div class="menu_body"
  202. <a href="TF_Product.aspx?id=67">配件類</a> <a href="TF_Product.aspx?id=86">標準件</a> 
  203. </div> 
  204. <p class="menu_head">其他</p> 
  205. <div class="menu_body"
  206. <a href="TF_Product.aspx?id=66">郵費差額</a> <a href="TF_Product.aspx?id=69">工程類服務費用</a> 
  207. <a href="TF_Product.aspx?id=78">折扣</a> <a href="TF_Product.aspx?id=88">設備</a> 
  208. </div> 
  209. </div> 
  210. </td> 
  211. <td width="660" valign="top"
  212. <div style="border-bottom:1px solid #DFEDFA; padding-left:2%; margin-left:2%;"
  213. 產品類別:<asp:DropDownList ID="ddlProductType" runat="server" DataTextField="pt_name" DataValueField="pt_id"
  214. </asp:DropDownList> 
  215.  
  216. 關鍵字:<asp:TextBox ID="txtGJZ" runat="server"></asp:TextBox> 
  217.  
  218. <asp:Button ID="btnSel" runat="server" Text="搜索" onclick="btnSel_Click" /> 
  219. </div> 
  220. <div> </div> 
  221. <div> 
  222. <asp:Repeater ID="rp" runat="server"
  223. <ItemTemplate> 
  224. <div style="margin-left:2%; border:1px solid #DFEDFA; padding:3px; margin-top:2px; margin-bottom:3px;"
  225. <table width="100%"
  226. <tr height="24px"
  227. <td rowspan="4" width="90px"
  228. <asp:Image ID="Image1" ImageUrl="~/Product_pic/NoPic.jpg" runat="server" Width="90px" Height="90px" /> 
  229. </td> 
  230. <td width="9px"> </td> 
  231. <td width="60px">產品型號:</td> 
  232. <td><span style="float:left"><%#Eval("pr_guige")%></span><span style="float:right;"><a href="#">查看詳情</a></span></td> 
  233. </tr> 
  234. <tr height="24px"
  235. <td width="9px"> </td> 
  236. <td>產品編碼:</td> 
  237. <td><%#Eval("pr_bianma")%></td> 
  238. </tr> 
  239. <tr height="30px"
  240. <td width="9px"> </td> 
  241. <td>產品描述:</td> 
  242. <td><%#Eval("pr_ms")%></td> 
  243. </tr> 
  244. <tr><td height="8px"> </td></tr> 
  245. </table> 
  246. </div> 
  247. </ItemTemplate> 
  248. </asp:Repeater> 
  249. <div style="height:22px; margin-left:2%;" align="right"
  250. <webdiyer:AspNetPager ID="AspNetPager1" CssClass="anpager" runat="server" FirstPageText="首頁" LastPageText="尾頁" NextPageText="下一頁" PrevPageText="上一頁" 
  251. onpagechanged="AspNetPager1_PageChanged" PageSize="6" ShowMoreButtons="False" ShowPageIndexBox="Never"
  252. </webdiyer:AspNetPager> 
  253. </div> 
  254. </div> 
  255.  
  256. </td> 
  257. </tr> 
  258. </tbody> 
  259. </table> 
  260. <!--版權聲明--> 
  261. <table width="878" border="0" align="center"
  262. <tbody> 
  263. <tr> 
  264. <td> 
  265. <img src="./Index_files/foot_02.gif" usemap="#foot" width="878"
  266. </td> 
  267. </tr> 
  268. </tbody> 
  269. </table> 
  270. </form> 
  271. </body> 
  272. </html> 

后臺代碼

 

 
  1. Tb_productsHelper helper = new Tb_productsHelper(); 
  2. IList<Tb_productsInfo> list = helper.GetAllListBySql(product_sql); 
  3. this.AspNetPager1.RecordCount = list.Count;//綁定總數量 
  4. this.AspNetPager1.AlwaysShow = true
  5. //先聲明一個分頁類對象 
  6. PagedDataSource ps = new PagedDataSource(); 
  7. ps.AllowPaging = true
  8. ps.PageSize = this.AspNetPager1.PageSize; 
  9. ps.CurrentPageIndex = this.AspNetPager1.CurrentPageIndex-1; 
  10. ps.DataSource = list; 
  11. this.rp.DataSource = ps; 
  12. this.rp.DataBind(); 


注:相關教程知識閱讀請移步到ASP.NET教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 5xx免费看| 免费h片网站| 色婷婷av一区二区三区久久 | 91av99| h视频免费在线观看 | 最新毛片在线观看 | 羞羞色在线观看 | 黄色大片在线免费看 | 草久网 | 中文字幕综合 | 久久精品视频12 | 国产乱色精品成人免费视频 | 美女亚洲综合 | 亚洲综人网 | 国产欧美亚洲精品 | 毛片视频免费播放 | 日日鲁夜夜视频热线播放 | 国产精品久久久久久模特 | 毛片一区二区三区四区 | 亚洲日色| 国产一有一级毛片视频 | 一级黄色免费观看视频 | 欧美成人免费看 | 久久久久国产成人精品亚洲午夜 | 性欧美一区 | 中文字幕在线免费看 | 日本黄色免费片 | 久久精国| 久章草影院 | qyl在线视频精品免费观看 | 国产三级a三级三级 | 一区二区三区欧洲 | 男男羞羞视频网站国产 | 91小视频在线观看免费版高清 | av在线成人 | 91成人在线免费观看 | 国产精品久久久久久久hd | 澳门一级淫片免费视频 | 精品久久www | 毛片网站视频 | 中文字幕在线观看亚洲 |