| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 563 人关注过本帖
标题:ASP分页问题?
只看楼主 加入收藏
xh4010
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2006-2-25
收藏
 问题点数:0 回复次数:2 
ASP分页问题?

制作了一个ASP分页程序,在显示本页记录后rs.AbsolutePage会自动加1,为什么会这样,而翻页链接是根据rs.AbsolutePage而变,rs.AbsolutePage值与显示出来的页面数值不同?请问错在哪里:

<script language=javascript>
//点击"[第一页]"时响应:
function PageFirst()
{
document.form1.CurrentPage.selectedIndex=0;
document.form1.CurrentPage.onchange();
}
//点击"[上一页]"时响应:
function PagePrior()
{
document.form1.CurrentPage.selectedIndex--;
document.form1.CurrentPage.onchange();
}
//点击"[下一页]"时响应:
function PageNext()
{
document.form1.CurrentPage.selectedIndex++;
document.form1.CurrentPage.onchange();
}
//点击"[最后一页]"时响应:
function PageLast()
{
document.form1.CurrentPage.selectedIndex=document.form1.CurrentPage.length-1;
document.form1.CurrentPage.onchange();
}
//选择"第?页"时响应:
function PageCurrent()
{ //data_list.asp是本程序的文件名
document.form1.action='data_list.asp?Page='+(document.form1.CurrentPage.selectedIndex+1)
document.form1.submit();
}
</Script>

<%
data_progress="完成"
data_exam=false
set rs=server.createobject("adodb.recordset")
rs.CursorLocation=adUseClient
rs.PageSize=5
sql = "select * from dtp_data where data_progress='"&data_progress&"' and data_exam="&data_exam&" order by data_date_end asc"
rs.open sql,conn,1,1
total=rs.recordcount
%>
<form name="form1" method="post">
<%IF rs.Eof THEN
Response.Write("<font size=2 color=#000080>[数据库中没有记录!]</font>")
ELSE
If Request("CurrentPage")="" Then
rs.AbsolutePage=1
Else
rs.AbsolutePage=CLng(Request.form("CurrentPage"))
End If
%>

'显示表头

<%For i=1 to rs.PageSize%> '循环显示本页记录

'显示记录内容

<%
rs.movenext
if rs.eof then exit for
Next
%>

''翻页超链接
<%
Response.Write("第<select size=1 name=CurrentPage onchange=PageCurrent()>")
For c=1 to rs.PageCount
if rs.AbsolutePage=c then
Response.Write("<option selected>"&c&"</option>") ''当前页码
else
Response.Write("<option>"&c&"</option>")
end if
Next
Response.Write("</select>页 ")

if rs.PageCount=1 then
Response.Write("[第一页] [上一页] [下一页] [最后一页] ")
else
if rs.AbsolutePage=1 then
Response.Write("[第一页] [上一页] ")
Response.Write("[<a href=javascript:PageNext()>下一页</a>] ")
Response.Write("[<a href=javascript:PageLast()>最后一页</a>] ")
else
if rs.AbsolutePage=rs.PageCount then
Response.Write("[<a href=javascript:PageFirst()>第一页</a>] ")
Response.Write("[<a href=javascript:PagePrior()>上一页</a>] ")
Response.Write("[下一页] [最后一页] ")
else
Response.Write("[<a href=javascript:PageFirst()>第一页</a>] ")
Response.Write("[<a href=javascript:PagePrior()>上一页</a>] ")
Response.Write("[<a href=javascript:PageNext()>下一页</a>] ")
Response.Write("[<a href=javascript:PageLast()>最后一页</a>] ")
end if
end if
end if
response.write rs.AbsolutePage
response.write request("page")
rs.close
set rs=nothing
end if
%>
</form>

[此贴子已经被作者于2006-3-29 21:04:22编辑过]

搜索更多相关主题的帖子: ASP 
2006-03-29 20:56
caozhiping88
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-4-1
收藏
得分:0 

个为大哥帮我看看我这个分页程序错在那里

第一个页面 这是曹志平.asp页面


<!-- #include file="conn.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<%
set rs=server.CreateObject("adodb.recordset")
sql="select * from product1"
set rs=conn.execute(sql)
do while not rs.eof
%>
<body>
<table width="200" border="1" align="center">
<tr>
<td height="39"><a href="曹志平.asp?id=<%=rs("id")%>"><%=rs("name")%></a></td>
</tr>
</table>
<%
rs.movenext
loop
%>
</body>
</html>
第二个页面 这是曹志平1.asp页面

<!-- #include file="conn.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<%
idd=request("id")
set rs=server.CreateObject("adodb.recordset")
'sql="select * from product2"
'set rs=conn.execute(sql)
rs.open "select * from product2 where idd='"&idd&"' order by idd desc",conn,1,1
rs.pagesize=3
page=1
if not isempty(Request.querystring("page")) then
page=csng(request.querystring("page"))
if page>rs.pagecount then
page=rs.pagecount
elseif page<1 then
page=1
end if
end if
rs.AbsolutePage=page
%>
<body>
<table width="293" border="1" align="center">
<tr>
<td width="83">&nbsp;</td>
<td width="85">&nbsp;</td>
<td width="103">&nbsp;</td>
</tr>
</table>
<% for i=1 to rs.pagesize %>
<table width="293" border="1" align="center">
<tr>
<td width="83"><%=rs("num")%></td>
<td width="85"><%=rs("name")%></td>
<td width="103"><%=rs("photo")%></td>
</tr>
</table>
<%
rs.movenext
next
%>
<a href="曹志平.asp?page=<%=page-1%>">上一页</a>
<a href="曹志平.asp?page=<%=page+1%>">下一页</a>
<%
rs.close
%>
</body>
</html>


它提示的错误是
技术信息(用于支持人员)

错误类型:
ADODB.Recordset (0x800A0BB9)
参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
/mingbo/曹志平.asp, 第 24 行


浏览器类型:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)

网页:
GET /mingbo/曹志平.asp

时间:
2006年4月1日, 14:58:35


详细信息:

2006-04-01 16:18
zdzycx
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2006-3-1
收藏
得分:0 

各位大哥,帮忙看下这个分页代码
点击前两次都正常进入,第三次链接到不正确的了
************分页部分*******************
on error resume next
if request.querystring("page")="" then page=1:else:page=cint(request.querystring("page")) '的到网址中的页数 page=?
dim sql,rs,top
top = false
if page = 1 then
sql = "Select article_id,article_title,article_author,article_time,article_read from [WMS_Article] where

article_class="&class_id&" and Instr(article_property,'|1|')>0 order by article_id desc"
set rs = Sailing.Execute(sql)
do while not rs.eof
top = True
tmp = tmp & "<tr>"
tmp = tmp & "<td class=list><img src='"&root&"images/arrow2.gif' align='absmiddle' title='置顶文

章'>&nbsp;<a href='article_view.asp?id="&rs(0)&"' title='作者:"&rs(2)&Chr(10)&"时间:"&rs(3)&Chr(10)&"点击:"&rs(4)&"'>"
if len(rs(1))> Sailing.ClassSetting(class_id,10) then
tmp = tmp & left(rs(1),Sailing.ClassSetting(class_id,10)) & Sailing.ClassSetting(class_id,11)
else
tmp = tmp & rs(1)
end if
tmp = tmp & "</a>"
if DateDiff("D",rs(3),now())< Sailing.ChannelSetting(Sailing.ClassSetting(class_id,2),11) then
tmp = tmp & "&nbsp;&nbsp;<img src='"&root&"images/new.gif' align='absmiddle'>"
end if
tmp = tmp & "</td>"
tmp = tmp & "<td align='center' class=list>"&rs(2)&"</td>"
tmp = tmp & "<td align='center' class=list>"&FormatDateTime(rs(3),2)&"</td>"
tmp = tmp & "<td align='center' class=list>"&rs(4)&"</td>"
tmp = tmp & "</tr>"
rs.movenext
loop
rs.close
set rs=nothing
end if
set rs=server.createobject("adodb.recordset")
rs.open "Select article_id,article_title,article_author,article_time,article_read from [WMS_Article] where

article_class="&class_id&" and Instr(article_property,'|1|')<=0 order by article_id desc",Conninfo,1,1

rs.pagesize=Sailing.ClassSetting(class_id,9) '每页显示的数量
rs.AbsolutePage=page

if page>rs.pagecount and top=false then
tmp = tmp &"<tr><td colspan=4><li>当前还没有任何文章被创建</td></tr>"
end if

for i=0 to rs.pagesize-1 '显示具体的数据内容了,i+(page*13-13)+1 这个解决分页后显示具体的编号
if rs.eof then exit for
tmp = tmp & "<tr>"
tmp = tmp & "<td class=list><img src='"&root&"images/arrow.gif' align='absmiddle'>&nbsp;<a

href='article_view.asp?id="&rs(0)&"' title='作者:"&rs(2)&Chr(10)&"时间:"&rs(3)&Chr(10)&"点击:"&rs(4)&"'>"
if len(rs(1))>Sailing.ClassSetting(class_id,10) then
tmp = tmp & left(rs(1),Sailing.ClassSetting(class_id,10)) & Sailing.ClassSetting(class_id,11)
else
tmp = tmp & rs(1)
end if
tmp = tmp & "</a>"
if DateDiff("D",rs(3),now())< Sailing.ChannelSetting(Sailing.ClassSetting(class_id,2),11) then
tmp = tmp & "&nbsp;&nbsp;<img src='"&root&"images/new.gif' align='absmiddle'>"
end if
tmp = tmp & "</td>"
tmp = tmp & "<td align='center' class=list>"&rs(2)&"</td>"
tmp = tmp & "<td align='center' class=list>"&FormatDateTime(rs(3),2)&"</td>"
tmp = tmp & "<td align='center' class=list>"&rs(4)&"</td>"
tmp = tmp & "</tr>"
rs.movenext

next
tmp = tmp &"<tr height=26>"
tmp = tmp &"<td colspan=4><div align='right'>"

dim PageName
PageName = Request.ServerVariables("PATH_INFO")&"?"&request.ServerVariables("QUERY_STRING")
tmp = tmp &"分页: "
if page>1 then tmp = tmp & "<A href='"&PageName&"&page=1'><font face='webdings'>9</font></a><a

href='"&PageName&"&page=" & page-1 & "'><font face='webdings'>7</font></a> ":else:tmp = tmp & "<font

face='webdings'>9</font><font face='webdings'>7</font> "

dim P_start
if len(page)=1 then
P_start=1
elseif right(page,1)=0 then
P_start=page-9
else
P_start=page - (right(page,1)-1)
end if
dim P_end
if P_start+9 <= rs.pagecount then
P_end = P_start+9
else
P_end = rs.pagecount
end if

for i = p_start to P_end
if i=page then
tmp = tmp & "<b><font color='#FF0000'>"& i & "</font></b> "
else
tmp = tmp & "<A href='"&PageName&"&page=" & i & "'>" & i & "</a> "

end if

next

if page<rs.pagecount then tmp = tmp & "<a href='"&PageName&"&page=" & page+1 & "'><font

face='webdings'>8</font></a><a href='"&PageName&"&page=" & rs.pagecount & "'><font face='webdings'>:</font></a> ":else:tmp =

tmp & "<font face='webdings'>8</font><font face='webdings'>:</font> "
tmp = tmp &" ["&page&"/"&rs.pagecount&"页]["&rs.pagesize&"条/页]"

rs.close '释放资源
set rs=nothing
tmp = tmp & "</div></td>"
tmp = tmp & "</tr>"
tmp = tmp & "</table>"
GetList = tmp


End Function


2006-04-01 17:21
快速回复:ASP分页问题?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017822 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved