流水落花春去也的:ASP 分页问题2??????

来源:百度文库 编辑:高考问答 时间:2024/05/01 23:03:53
rs.PageSize = 4
rs.CursorLocation = 3
rs.Open sql,cn, 0, 2, 1
pre = true
last = true
page = trim(Request.QueryString("page"))

if len(page) = 0 then
intpage = 1
pre = false
else
if cint(page) =< 1 then
intpage = 1
pre = false
else
if cint(page) >= rs.PageCount then
intpage = rs.PageCount
last = false
else
intpage = cint(page)
end if
end if
end if
if not rs.eof then
rs.AbsolutePage = intpage
end if
%>

<%
for i=1 to rs.PageSize
if rs.EOF or rs.BOF then exit for
%> </td>
<tr>
<td width="368" valign="bottom"><a href="display.asp?keyno=<%=rs("keyno")%>"target="_parent"><%=rs("title8")%></a></td>
</tr>
<tr>
<td><%
rs.movenext
next
%></td>
</tr>
</table>

<table width="99%" border="1" cellpadding="2" cellspacing="2" bordercolorlight="#808080" bordercolordark="#ffffff">
<tr>
<%if rs.pagecount > 0 then%>
<td width="13%" align="left">当前页<%=intpage%>/<%=rs.PageCount%></td>
<%else%>
<td width="41%" align="left">当前页0/0</td>
<%end if%>
<td width="46%" align="right"><a href="case.asp?classcode=<%=rs("classcode")%>&page=1">首页</a>|
<%if pre then%>
<a href="case.asp?classcode=<%=rs("classcode")%>&page=<%=intpage -1%>">上页</a>|
<%end if%>
<%if last then%>
<a href="case.asp?classcode=<%=rs("classcode")%>&page=<%=intpage +1%>">下页</a> |
<%end if%>
<a href="case.asp?classcode=<%=rs("classcode")%>&page=<%=rs.PageCount%>">尾页</a>|转到第
<select name="sel_page" onChange="javascript:location=this.options[this.selectedIndex].value;">
<%
for i = 1 to rs.PageCount
if i = intpage then%>
<option value="case.asp?classcode=<%=rs("classcode")%>&page=<%=i%>" selected="selected"><%=i%></option>
<%else%>
<option value="case.asp?classcode=<%=rs("classcode")%>&page=<%=i%>"><%=i%></option>
<%
end if
next
%>
</select>
页</font> </td>
</tr>
</table>
最后一页出错?

这么复杂啊?我这里提供一下我自己网站上的分页代码吧

Set rs = Server.CreateObject ("ADODB.Recordset")
sql="SELECT * FROM table ORDER BY myTime DESC"
rs.open sql , connStr,1,3

page=1 ' 设置变量PAGE=1
rs.PageSize = 30 '每页显示记录数
total=rs.RecordCount

if Not IsEmpty(Request("Page")) then '如果PAGE已经初始化...
Page = CInt(Request("Page")) '接收PAGE并化为数字型赋给PAGE变量
if Page > rs.PageCount then '如果接收的页数大于总页数
rs.AbsolutePage = rs.PageCount '设置当前显示页等于最后页
elseif Page <= 0 then '如果page小于等于0
Page = 1 '设置PAGE等于第一页
else
rs.AbsolutePage = Page '如果大于零,显示当前页等于接收的页数
end if
End if
Page = rs.AbsolutePage

以下是输出分页导航条
if page>1 then
response.write"<a Href='?Page=1'><u>首页</u></a> <a Href='?Page="&(page-1)&"'><u>上一页</u></a>"
elseif page=1 then
response.write"首页 上一页"
end if
if page<>rs.pagecount then
response.write" <a Href='?Page="&(page+1)&"'><u>下一页</u></a> <a Href='?Page="&rs.PageCount&"'><u>尾页</u></a> "
elseif page=rs.pagecount then
response.write" 下一页 尾页 "
end if
response.write"共有<span class='ft_red'>"&total&"</span>条记录,<span class='ft_red'>"&rs.PageSize&"</span>条/页,页数:<span class='ft_red'>"&rs.PageCount&"</span>,页次:<span class='ft_red'>"&page&"/"&rs.PageCount&"</span>,转到第"
response.write"<select class='form_input' onChange='javascript:location.href=this.options[selectedIndex].value'>"
for j=1 to rs.pageCount
if j=page then
response.write"<option value='?page="&j&"' selected>"&j&"</option>"
else
response.write"<option value='?page="&j&"'>"&j&"</option>"
end if
Next
response.write"</select>页"
rs.close:Set rs = Nothing