找回密码
 注册
搜索
热搜: 回贴

ASP:分页的显示--*前后翻滚10页的实现

2009-12-13 13:41| 发布者: admin| 查看: 52| 评论: 0|原作者: 心然

★<% setcon=server.Cre......


<%
set con=server.CreateObject("ADODB.Connection")
strConnection="Data Source=xxxxxxx;"
con.Open strConnection

set rs = Server.CreateObject("ADODB.Recordset")
chartSQL="select ID,name,category_one from goods "
rs.Open chartSQL,con,1,3
if rs.EOF or rs.BOF then '如果为空
response.end
end if
pagesize=10 '每页显示10条记录
pagecuont=rs.PageCount '总页数
recordcount=rs.RecordCount
dim pagenum '当前页码
dim currentRecord '当前页的记录数,对于末页其值不等于pagesize
if Request.QueryString ("pageNum")="" then
pageNum=1
else
pageNum=Request.QueryString ("pageNum")
rs.AbsolutePage =trim(Request.QueryString ("pageNum"))
end if
%>





New Page 1




商品修改页面









<%
for i=1 to rs.PageSize
if rs.EOF or rs.BOF then '本条件判断是否到了尽头
exit for
end if
%>






<%
currentRecord=currentRecord+1 '取的当前页的记录数
rs.MoveNext
next
rs.Close
%>

编号 


商品名 

 
主分类


操作 

<%=rs("ID")%><%=rs("name")%> <%=rs("category_one")%>

onclick="javascript:window.open('tomodify.asp?id=<%=rs("ID")%>&zfenlei=<%=rs("category_one")%>','','resizable=no,width=240,height=160')">
 


合计<%=recordCount%> 条记录 | 第
<%
pageNum_record=(pageNum-1)*pageSize+1 '初始记录位置
pageNum_record_=pageNum_record+currentRecord-1 '末记录位置
Response.Write pageNum_record
%>
-<%=pageNum_record_%>条 | 第<%=pageNum%>页 |共<%=pagecuont%>页
<%
if pagecuont >0 then '防止当前返回的为空记录,即数据库中该数据集为空
if pageNum > 1 then %>
首页
<%
else Response.Write "首页"
end if
if pageNum > 10 then
'如有需要,请在这里添上如果不足10页时该实现前n页的代码,
'请参考下面的如果后面不足10页时该怎么样处理的代码和思路
%>
前10页
<%
end if
if (pageNum+10) < pagecuont then
'这里也相同参考下面的思路
%>
下10页
<%
end if
if (pageNum+10) < pagecuont then
'这里判断后面是否还有10页
endpage=pageNum+9
else
endpage=pageCount
end if
for i=pageNum to endPage
%>
第<%=i%>页
<%
next
if pageNum <> pageCount then
%>
末页
<%
end if
end if 'end of --->if pageCount >0 then
%>



最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 21:24 , Processed in 0.154064 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部