大侠帮忙,分页问题!急,在线等!!问题解决,马上给分。
<%@LANGUAGE= "VBSCRIPT " CODEPAGE= "936 "%>
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 无标题文档 </title>
<style type= "text/css ">
<!--
.style1 {font-size: 12px}
-->
</style>
</head>
<body>
<!--#include file= "conn.asp " -->
<% OpenDB()
Set rs = Server.CreateObject ( "ADODB.Recordset ")
sql= "select id,title,content,subid from TravelNews where subid=2 "
rs.Open sql, conn, 3,1
'dim sql,rs
'sql= "select id,title,content,subid from TravelNews where subid=2 "
'set rs=conn.execute(sql) '将记录读到RS中
'if rs.eof or rs.bof then
'response.Write( "没有新闻! ")
'response.End()
'end if
%>
<%
rs.PageSize = 2
curpage=cint(Request.QueryString( "Page "))
if IsEmpty(curpage) or curpage= " " or isnull(curpage) then '第一次调用时
CurPage = 1
rs.AbsolutePage=CurPage
else
if CurPage> rs.PageCount then
CurPage=rs.PageCount
rs.AbsolutePage=CurPage
elseif request( "Page ") <= 0 then
CurPage = 1
rs.AbsolutePage=CurPage
else
rs.AbsolutePage = CurPage
end if
End if
'abpage=rs.absolutepage//如果把rs.absolutepage记下来,再在 “当前是第 <%=abpage%> 页”处调用显示是正常的,但是如果不把rs.absolutepage用变量记下来,也就是去掉“abpage=rs.absolutepage”,到后边直接用“当前是第 <%=rs.absolutepage%> 页”就会出先负数,为什么啊?是不是“rs.movenext”对“rs.absolutepage”有影响啊?
%>
<%
for i=1 to rs.pagesize
if rs.eof then
exit for
end if
%>
<table width= "765 " >
<tr>
<td width= "490 "> <span class= "style1 "> <%=rs( "title ")%> </span> </td>
<td width= "126 "> <div align= "center "> <a href= "SubEditRunNews.asp?id= <%=rs( "id ")%> " class= "style1 " > 编辑 </a> </div> </td>
<td width= "133 "> <div align= "center "> <a href= "DelRunNews.asp?id= <%=rs( "id ")%> " class= "style1 "> 删除 </a> </div> </td>
</tr>
</table>
<%
rs.movenext
next
%>
<table width= "765 " border= "0 " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td> <table width= "70% " border= "0 " align= "right ">
<tr>
<% if curpage> 1 then %>
<td width= "13% "> <div align= "center "> <a href= "editrunnews.asp?page=1 " class= "style1 "> 首页 </a> </div> </td>
<td width= "19% "> <div align= "center "> <a href= "editrunnews.asp?page= <%=CurPage-1%> " class= "style1 "> 上一页 </a> </div> </td>
<% end if
if curpage <rs.pagecount then
%>
<td width= "22% "> <div align= "center "> <a href= "editrunnews.asp?page= <%=CurPage+1%> " class= "style1 "> 下一页 </a> </div> </td>
<td width= "16% "> <div align= "center "> <a href= "editrunnews.asp?page= <%=rs.pagecount%> " class= "style1 "> 尾页 </a> </div> </td>
<% end if %>
<td width= "13% "> <div align= "center " class= "style1 "> 总共 <%=rs.pagecount%> 页 </div> </td>
<td width= "17% "> <div align= "center " class= "style1 "> 当前是第 <%=rs.absolutepage%> 页 </div> </td>
</tr>
</table> </td>
</tr>
</table>
<% rs.close
set rs=nothing
closeDB()
%>
</body>
[解决办法]
应该不是程序问题,可能是rs.movenext最后已经跳出本页所属数据集,这个没关系
当前页应该是 <%=CurPage %>
如果非要弄个究竟的话,试试把循环设为rs.PageSize-1,看看还是不是-1了