惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
A
Arctic Wolf
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Proofpoint News Feed
S
Schneier on Security
The Cloudflare Blog
Security Latest
Security Latest
S
SegmentFault 最新的问题
L
Lohrmann on Cybersecurity
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
Cyber Attacks, Cyber Crime and Cyber Security
K
Kaspersky official blog
Latest news
Latest news
月光博客
月光博客
aimingoo的专栏
aimingoo的专栏
P
Privacy & Cybersecurity Law Blog
F
Fortinet All Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
美团技术团队
博客园 - 叶小钗
H
Help Net Security
博客园 - 【当耐特】
云风的 BLOG
云风的 BLOG
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
A
About on SuperTechFans
WordPress大学
WordPress大学
Cloudbric
Cloudbric
IT之家
IT之家
Last Week in AI
Last Week in AI
S
Securelist
Google Online Security Blog
Google Online Security Blog
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
L
LINUX DO - 最新话题
Know Your Adversary
Know Your Adversary
爱范儿
爱范儿
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
G
Google Developers Blog
C
CERT Recently Published Vulnerability Notes
宝玉的分享
宝玉的分享
博客园 - Franky
TaoSecurity Blog
TaoSecurity Blog
P
Proofpoint News Feed
大猫的无限游戏
大猫的无限游戏
Jina AI
Jina AI
L
LINUX DO - 热门话题
N
News and Events Feed by Topic
B
Blog

博客园 - loway

必须掌握的八个DOS命令 [转] asp免费源代码 ASP 中 Split 函数的实例 - loway ASP:Recordset对象方法 ASP错误编码大全 实用网页代码 - loway - 博客园 ASP各种存储过程使用指南 - loway - 博客园 翻页的存储过程 纯ASP上传图像文件到数据库的最佳例子 - loway - 博客园 禁止右键、选择、粘贴、shift、ctrl、alt..... - loway - 博客园 弹出式说明窗口---JavaScript的使用 asp之fso操作大全代码奉送 JS的正则表达式 ASP开发中存储过程应用全接触 数据库设计 正则表达式语法 水晶报表参数编程示例代码 经典水晶报表设计——国际销售合同! .NET环境下水晶报表使用总结
在ASP中轻松实现记录集分页显示
loway · 2006-03-27 · via 博客园 - loway

在ASP中轻松实现记录集分页显示

文章来自 (http://edu.chinaz.com )
大家都知道在Dreamwerver中可以很方便地实现记录集的分页显示,但是生成的代码的确很庞大,影响了网页的显示速度,看起来条理也不是很清晰,那么,可不可以用简单的方式实现同样的功能呢?当然可以,笔者通过以下一些简单的代码就实现了记录集的分页显示,现在拿出来大家一起分享。

  主要代码如下:

<%
 If rs1.recordcount>0 Then ’ 记录集不为空则处理记录
  rs1.pagesize = 10 ’ 设置每页显示的记录数
  num=rs1.recordcount ’ 记录总数
  pagenum=rs1.pagecount ’ 页总数
  page=request("page") ’ 获取页码的原始信息
  ’ 处理页码原始信息的开始! 
  If page <> "" then
   page = cint(page)
  if err.number <> 0 then
   err.clear
   page = 1
  end if
  if page < 1 then
   page = 1
  end if
 else
  page = 1
 End if
 if page*rs1.pagesize > num and not((page-1)*rs1.pagesize < num)then
  page=1
 end if
 ’ 处理页码原始信息的结束!设置当前页码
 rs1.absolutepage = page
%>
<!--判断当前页是否是最后一页,并根据判断设置记录的重复显示-->
<% if page<>pagenum then
   lablenum=rs1.pagesize
  else
   lablenum=num-(page-1)*rs1.pagesize
  end if
  for i=1 to lablenum
%>
<tr bgcolor="#FFFFFF">
 <td height="25"><div align="center"><%=(rs1.Fields.Item("id").Value)%></div></td>
 <td><div align="center"><%=(rs1.Fields.Item("名称").Value)%></div></td>
 <td><div align="center"><%=(rs1.Fields.Item("地址").Value)%></div></td>
 <td><div align="center"><%=(rs1.Fields.Item("类别").Value)%></div></td>
 <td><div align="center"><%=(rs1.Fields.Item("最后修改").Value)%></div></td>
 <td><div align="center"><%=(rs1.Fields.Item("修改人").Value)%></div></td>
</tr>
<%
 rs1.movenext
next
%>
<!--当前页的记录显示结束,以下代码为记录集分页链接代码-->
<table width="70%" border="0" align="center" cellpadding="0" cellspacing="0">
 <tr> 
  <td height="35"> 
   <div align="right">
    <font color="#333333">
     共有 <%=num%> 个链接 | 
     <a href=linkadmin.asp?page=1>首页</a> | 
     <%if page>1 then%><a href=linkadmin.asp?page=<%=page-1%>><%end if%>上一页</a> | 
     <%if page<pagenum then%><a href=linkadmin.asp?page=<%=page+1%>><%end if%>下一页</a> | 
     <a href=linkadmin.asp?page=<%=pagenum%>>尾页</a> | 
      页次:<%=page%>/<%=pagenum%>页 | 
      共<%=pagenum%>页
    </font>
   </div>
  </td>
 </tr>
</table>
<!--记录集分页链接代码结束,记录集为空时执行以下代码-->
<%else%>
<tr bgcolor="#FFFFFF">
<td height="25" colspan="6"><div align="center"><% response.Write("没有结果可显示!") %>
</div></td>
</tr>
<%
end if
rs1.Close()
Set rs1 = Nothing
%>