请问如何在asp中如何实现分页显示?

meimei 2000-05-07 06:13:00
一次返回的查询结果太多了,我想分页显示,请问如何象csdn的网页那样,使用如href=index.asp?page=3&room=7>3</a>][<a href=index.asp?page=4&room=7>4</a>][<a……之类的代码实现分页显示?该如何下手做起?
...全文
161 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
王释之 2000-05-08
  • 打赏
  • 举报
回复
不好意思!
外科(<%=rootRs.RecordCount %>):                          </STRONG>第 <SELECT
id=select1 name=select1 onchange=location=this.options[this.selectedIndex].value >
<% If rootRs.pagecount>1 then
rootRs.AbsolutePage=Request.QueryString
%>
<option selected value="<%=Request.QueryString%>"><%=Request.QueryString%></option>

<%
For i=1 to rootRs.pagecount
%>
<option value="index.asp?<%=i%>" ><%Response.Write i%></option>
<%
Next
end if%>
</SELECT><FONT size=2><FONT
size=3>页</FONT></p>
王释之 2000-05-08
  • 打赏
  • 举报
回复
如果用下拉框,可用:
<p align="left"><FONT size=2>   </FONT>
<P align=left style="margin-top: 0; margin-bottom: 0"><STRONG>     
外科(<%=rootRs.RecordCount %>):                          </STRONG>第 <SELECT
id=select1 name=select1><option selected value="1">1</OPTION>

<% If rootRs.pagecount>1 then
For i=1 to rootRs.pagecount
%>
<option value="<%=i%>"><%Response.Write i%></option>
<%
Next
end if%>
</SELECT><FONT size=2><FONT
size=3>页</FONT></p>
meimei 2000-05-07
  • 打赏
  • 举报
回复
谢谢了,我去试试。
flyfox 2000-05-07
  • 打赏
  • 举报
回复
给你一个例子。

<html>

<head>
<!--#include virtual="/adovbs.inc" -->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>test4</title>
</head>

<body>
<%
sql="select * from jifei"
dsn="dsn=access"
mypage=request.querystring("whichpage")
if mypage="" then
mypage=1
end if
mypagesize=request.querystring("pagesize")
if mypagesize="" then
mypagesize=10
end if

set rstemp=server.createobject("adodb.recordset")
rstemp.cachesize=5
rstemp.open sql,dsn,adopenstatic

rstemp.movefirst
rstemp.pagesize=mypagesize
maxcount=cint(rstemp.pagecount)
rstemp.absolutepage=mypage
howmanyrecs=0
howmanyfields=rstemp.fields.count-1
response.write "Page "&mypage&" of "&maxcount&"<br>"
%>
<table border=1>
<tr>
<%
for i=0 to howmanyfields
%>
<td><b>
<% =rstemp(i).name %>
</B></TD>
<% next %>
</tr>
<% do while not rstemp.eof and howmanyrecs<rstemp.pagesize %>
<tr>
<% for i=0 to howmanyfields
%>
<td valign=top>
<% =rstemp(i) %></td>
<% next %>
</tr>
<%
rstemp.movenext
howmanyrecs=howmanyrecs+1
loop
rstemp.close
set rstemp=nothing
%>
</table><p>

<%
pad="00"
scriptname=request.servervariables("script_name")
for counter=1 to maxcount
if counter>=10 then
pad="0"
end if
if counter>=100 then
pad=""
end if
ref="<a href="&scriptname&"?whichpage="&counter
ref=ref&"&pagesize="&mypagesize&">"&pad&counter&"</A>"
response.write ref&" "
if counter mod 20=0 then
response.write "<br>"
end if
next
%>


</body>

</html>

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧