当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP分页函数

ASP
ASP 编程中20个非常有用的例子(一)
ASP 编程中20个非常有用的例子(二)
ASP基础教程:ADO存取数据库时如何分页显示
ASP基础教程:其它的ASP常用组件
ASP基础教程:学习ASP中子程序的应用
ASP基础教程之ASP程序对Cookie的处理
ASP基础教程之实例学习ASP Response 对象
ASP基础教程之ASP AdRotator 组件的使用
ADO初学者教程:ADO 通过GetString()加速脚本
初学者来认识OLEDB和ODBC的区别
ASP常见数学函数 Abs Atn Cos 等详细详解
VBScript新手入门初学教程:VBScript简介
有用的无声递交表单的客户端函数
Windows 2003 安装设置iis
ASP技巧实例:几行代码解决防止表单重复提交
ASP读sql数据时出现乱码问题的解决方法
ASP技巧实例:使用ASP记录在线用户的数量
ASP技巧实例:关于对表单操作的程序
ASP技巧实例:ASP实现最简洁的多重查询的解决方案
ASP实例:利用缓存提高数据显示效率

ASP分页函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 82 ::
收藏到网摘: n/a

Function ExportPageInfo(ByRef rs,curpage,i,LinkFile)
Dim retval, j, pageNumber, BasePage
retval = "第" & curpage & "页/总" & rs.pagecount & "页 " 
retval = retval & "本页" & i & "条/总" & rs.recordcount & "条 "
If curpage = 1 Then 
retval = retval & "首页 前页 " 
Else 
retval = retval & "<a href=’’" & LinkFile & "page=1’’>首页</a> <a href=’’" & LinkFile & "page=" & cstr(curpage - 1) & "’’>前页</a> " 
End If
If curpage = rs.pagecount Then 
retval = retval & "后页 末页"
Else
retval = retval & "<a href=’’" & LinkFile & "page=" & cstr(curpage + 1) & "’’>后页</a> <a href=’’" & LinkFile & "page=" & cstr(rs.pagecount) & "’’>末页</a>"
End if
retval = retval & "<br/>"
BasePage = (curpage \ 10) * 10
If BasePage > 0 Then retval = retval & " <a href=’’" & LinkFile & "page=" & (BasePage - 9) & "’’><<</a>"
For j = 1 to 10
pageNumber = BasePage + j
If PageNumber > rs.pagecount Then Exit For
If pageNumber = Cint(curpage) Then
retval = retval & " <font color=’’#FF0000’’>" & pageNumber & "</font>"
Else
retval = retval & " <a href=’’" & LinkFile & "page=" & pageNumber & "’’>" & pageNumber & "</a>"
End If
Next
If rs.pagecount > BasePage Then retval = retval & " <a href=’’" & LinkFile & "page=" & (BasePage + 11) & "’’>>></a>"
ExportPageInfo = retval
End Function



应用
<%
adoPageRS.open "SELECT * FROM news ORDER BY addtime DESC", conn, 1, 1
if err.number <> 0 then
response.write "数据库操作失败:"&err.description
else
if adoPageRS.eof and adoPageRS.bof then
response.write "没有记录"
else
%>
<div align="center"> 
<center>
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr class="big"> 
<td width="60%">新 闻 标 题</td>
<td width="25%" align="center">日期</td>
<td width="15%" align="center">操  作</td>
</tr>
<% 
adoPageRS.pagesize = 10 
adoPageRS.absolutepage = curpage 
for i = 0 to 9 
%>
<tr> 
<td><%= adoPageRS("title") %></td>
<td align="center"> 
<% = adoPageRS("addtime") %>
</td>
<td align="center"><a href=’’newsman.asp?action=edit&id=<%= adoPageRS("id")%>’’>编辑</a>