asp 分页问题!

zxlh 2003-12-10 02:58:34
if page="" then
page=1
end if
rs.PageSize=30
page=cint(page)

if page<1 then page =1
if page>rs.PageCount then page=rs.PageCount

rs.AbsolutePage=page

可以分页,但是当查询纪录为“0”时就出错了!
怎么作记录可以为0的查询!
...全文
37 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
a_zhe_20 2003-12-10
  • 打赏
  • 举报
回复
if rs.recordcount<>0 then
...
else
response.write "没有查询到纪录。"
end if
Primer2002cn 2003-12-10
  • 打赏
  • 举报
回复
给你二个过程,只需调用它即可
*******************************************************
Sub initPage(byval rs)
if rs.bof and rs.eof then
err_msg="没有你所查询的记录"
exit sub
end if
rs.PageSize=cntPageSize
TotalPage=rs.PageCount
intPageNo=trim(Request("PageNo"))
if request("cndok")<>"" then intPageNo=request("page")
If intPageNo = Empty Then
intPageNo = 1
Else
intPageNo = CInt(intPageNo)
'--- 如果超出最后一页 ---
If intPageNo > TotalPage Then
intPageNo = TotalPage
end if
End If
if intPageNo<TotalPage then
PageSize=intPageNo*cntPageSize
else
PageSize=rs.recordcount
end if
if PageSize=0 then
FirSize=0
else
FirSize=((intPageNo-1)*cntPageSize)+1
end if
rs.Absolutepage=intPageNo
End Sub
****************************************************************
2
*****************************************************************
Sub Display_Button(byval rs)

href_first= theScript & str & "&PageNo=1"
href_prev= theScript & str & "&PageNo=" & (intPageNo-1)
href_next= theScript & str & "&PageNo=" & (intPageNo+1)
href_last= theScript & str & "&PageNo=" & rs.pagecount

strnav_first= "<a href=" & href_first & ">首页</a>"
strnav_prev= "<a href=" & href_prev & ">上一页</a>"
strnav_next= "<a href=" & href_next & ">下一页</a>"
strnav_last= "<a href=" & href_last & ">末页</a>"
if rs.pagecount > 1 then
'在首页
if intPageNo = 1 then
strnav_first= "首页"
strnav_prev = "上一页"
end if
'在末页
if intPageNo = rs.pagecount then
strnav_next = "下一页"
strnav_last = "末页"
end if
else
strnav_first= "首页"
strnav_prev = "上一页"
strnav_next = "下一页"
strnav_last = "末页"
end if

strnav = strnav_first & " " & strnav_prev & " " & strnav_next & " " & strnav_last
if rs.recordcount<>-1 then
Response.Write "<center><form method='POST' action='" & theScript & str & "' id=form1 name='frmfoot'>"
Response.Write "<table border=1 width='90%'>"
Response.Write "<p><font color='#000080'>>>分页 " & strnav
Response.Write " 页次:<font color=ff0000>" & intPageNo & "</font>/"
Response.Write "<font color=0000ff>" & TotalPage
Response.Write "</font>页 共<font color=0000ff>" & rs.recordcount & "</font>条记录 <font color=0000ff>"
Response.Write cntPageSize & "</font>条记录/页 "
Response.Write "本页显示第<font color=0000ff>" & FirSize
Response.Write "</font>到第<font color=0000ff>" & PageSize & "</font>条"
Response.Write "<p> 转到:</font><input type='text' name='page' size=4 maxlength=10 >"
Response.Write "<input class=buttonface type='submit' value=' Goto ' name='cndok' >"
Response.Write "</table></form><center>" & vbCrLf
if rs.recordcount>0 then
rs.AbsolutePage = intPageNo
end if
end if
End Sub
***********************************************************************
sherrywear 2003-12-10
  • 打赏
  • 举报
回复
if not rs.eof then
if page="" then
page=1
end if
rs.PageSize=30
page=cint(page)

if page<1 then page =1
if page>rs.PageCount then page=rs.PageCount

rs.AbsolutePage=page
end if
angelheavens 2003-12-10
  • 打赏
  • 举报
回复
判断recordcount
vivisogood 2003-12-10
  • 打赏
  • 举报
回复
if not rs.bof then
分页部分
else
没有记录
angelheavens 2003-12-10
  • 打赏
  • 举报
回复
rs.pagesize=30
if rs.recordcount<>0 then
page = CLng(Request("page")) ' CLng 不可省略
If page < 1 Then
page = 1
end if
If page > rs.PageCount Then
page = rs.PageCount
end if
rs.AbsolutePage = page
zhangxdd 2003-12-10
  • 打赏
  • 举报
回复
在啊前在同判断是否是空记录
if(!rs.eof())
...

28,391

社区成员

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

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