自己常用的分页程序

本文介绍了一种在 ASP.NET 中实现数据分页的方法。通过使用 SQL 查询和 ADO.NET 对象模型,实现了对数据库中数据的有效分页显示。文章详细展示了如何构建 SQL 查询语句以实现模糊查询,并通过循环读取记录集来分页展示数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<iframe name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4490194096475053&amp;dt=1226297185750&amp;lmt=1226285422&amp;prev_slotnames=1891601125&amp;output=html&amp;slotname=3685991503&amp;correlator=1226297185718&amp;url=http%3A%2F%2Fwww.corange.cn%2Farchives%2F2008%2F08%2F1465.html&amp;ea=0&amp;ref=http%3A%2F%2Fwww.corange.cn%2Fhtml%2Fcorange__78.html&amp;frm=0&amp;ga_vid=2044451421.1225934970&amp;ga_sid=1226297173&amp;ga_hid=1656447314&amp;ga_fc=true&amp;flash=9.0.124.0&amp;u_h=768&amp;u_w=1024&amp;u_ah=715&amp;u_aw=1024&amp;u_cd=32&amp;u_tz=480&amp;u_java=true" frameborder="0" width="300" scrolling="no" height="250" allowtransparency></iframe>
dim rs,sql,key,strsql,page,i,x
key=request("key") '搜索关键字
strsql="?key="&key
page=cint(request("page"))
if page="" or page<=0 or isnumeric(page)=false then page=1
set rs=.....
sql="..... where .. like'%"%key&"%' or ... like'%"&key&"%'...."
rs.open sql......
if not rs.eof then
rs.movefirst
.....
i=0
do while not rs.eof and i<rs.pagesize
i=i+1
.........
.......
.....
..
rs.movenext
loop
else
page=0
end if
response.Write("共计"&rs.recordcount&"条 ")
response.Write("每页"&rs.pagesize&"条 ")
response.Write("第"&page&"/"&rs.pagecount&"页 ")
if page>1 and page<=rs.pagecount then response.Write("<a href="&strurl&"&page="&page-1&" class=l9>上一页</a> ")
if page<rs.pagecount and rs.pagecount>1 then response.Write("<a href="&strurl&"&page="&page+1&" class=l9>下一页</a>")
if rs.pagecount>1 then
response.Write(" 转到第<select onchange='javascript:location.href=this.options[selectedIndex].value'>")
for x=1 to rs.pagecount
if cint(page)=x then
response.Write("<option value="&strurl&"&page="&x&" selected>"&x&"</option>")
else
response.Write("<option value="&strurl&"&page="&x&">"&x&"</option>")
end if
next
response.Write("</select>页")
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值