ASP中怎么分页显示数据库里的数据

最好有例子是ASP.NET,C#语法的
2024-12-27 17:34:05
推荐回答(4个)
回答1:

Sub show()
logusername = replace(trim(request.Querystring("logusername")),"'","")
if logusername <> "" then
sql="select * from JB_log where username='"+ logusername +"' order by logid desc"
logpage = "&logusername="& logusername
logtext = "当前显示"& logusername &"的操作日志 | 显示全部"
else
sql="select * from JB_log order by logid desc"
End if
set rs = server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
%>





输入操作人:

 <%=logtext%>









<%
if userID=33 and usergroup=1 then
%>

<%
end if
%>

<%
if not(rs.Eof and rs.Bof) then
page = trim(request.form("page"))
if page = "" then page = trim(request.QueryString("page"))
if Not(IsNumeric(page)) or page = "0" then page = 1
rs.pageSize = 60
pageCount = rs.pageCount
if len(page) > 4 then page = pageCount
if Cint(page) > Cint(pageCount) then page = pageCount
rs.absolutepage = page
color2 = 0
for i = 1 to rs.pagesize
if rs.eof then exit for
if color2 mod 2 = 0 then
color1 = "Class=""table-dark"""
else
color1 = "Class=""table-light"""
end if
%>
>






<%
if userID=33 and usergroup=1 then
%>

<%
End if
%>

<%
rs.MoveNext
color2=color2+1
Next'i
End if
if userID=33 and usergroup=1 then
%>
>



<%
End if
%>

操作人 操作时间 操作内容/文章作者 操作理由/扣分 内容 操作时IP
<%=""&rtrim(rs("username"))&""%> <%=rtrim(rs("logtime"))%> <%=rtrim(rs("logC"))%> <%=rtrim(rs("reason"))%> ">
<%if trim(rs("oldcontent")) <> "" then response.Write("查看") end if%>
<%=rtrim(rs("logIP"))%>
">














<%
if pagecount < 1 then pagecount = 1
response.Write "页次:"& PAGECOUNT &"/" & page &"页 每页"& rs.pageSize &" 记录"&rs.recordCount&" "
%>
分页:
<%
beginpage = 1
endpage = CInt(pagecount)
page = CInt(page)
if pagecount >= 9 then
if page >= 5 then
beginpage = page - 4
if page <= (pagecount - 4) then
endpage = page + 4
else
endpage = pagecount
beginpage = pagecount - 4
end if
else
beginpage = 1
endpage = 9
end if
end if
if beginpage>1 then response.write " 9"
for j = beginpage to endpage
if j = page then
response.write" [" & j & "] "
else
response.write" [" & j & "] "
end if
next
if endpage < pagecount then response.write " :"
%>
转到:第



<%
rs.close
set rs = nothing
End Sub

回答2:

如果你用dreamweaver的话有一个更简单的办法,你先产生一个记录集然后
菜单,插入——〉应用程序对象——〉记录集分页——〉记录集导航条
只要按照提示就非常简单的就可以实现啦!

回答3:

使用ASP.NET中的分页控件就可以。

回答4:

刷分