asp如何让他分页显示?.每页显示10行
发布网友
发布时间:2024-09-26 21:47
我来回答
共2个回答
热心网友
时间:2024-10-28 16:25
直接改好就算了
下面给你贴段分页的代码你参考一下
这个是我刚写的一个系统的管理后台的分页显示管理
自己研究才有进步
说明 注意那个PAGE是分页的页码
conn.asp是一个数据库连接文件
<!--#include file="conn.asp"-->
<%
Page=Request.QueryString("Page")
if Int(Page)="" or int(page)<1 then
currentPage=1
else
currentPage=cint(Page)
end if
set rs=server.createobject("adodb.recordset")
sql="select * from tbl_article order by exacttime desc"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
rseof=1
else
rseof=2
MaxPerPage=23
PageUrl="admin_art_mnr.asp"
totalPut=rs.recordcount
if currentpage<1 then currentpage=1
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
end if
%>
<%
sub showContent
i=0
%>
<%
do while not rs.eof
%>
<tr>
<td width="30" align="center" class="table00"><%=rs("id")%></td>
<td width="340" align="center" class="table00"><a href="../showarticle.asp?id=<%=rs("id")%>" target="_blank"><% if len(rs("title"))<26 then %><%=rs("title")%><%else%><%=left(rs("title"),25)&"..."%><%end if%></a></td>
<td width="99" align="center" class="table00"><%=rs("username")%></td>
<td width="80" align="center" class="table00"><%=rs("time")%></td>
<td width="100" align="center" class="table00"><a href="article_edit.asp?id=<%=rs("id")%>" class="STYLE3">编</a>|<a href="article_del.asp?id=<%=rs("id")%>"><span class="STYLE4">删</span></a>|?</td>
</tr>
<%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
end sub
function showpage(totalnumber,maxperpage,filename)
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
%>
<div align="right">共<font color="#ff0000"><b><%=totalnumber%></b></font>篇文章
<%if CurrentPage<2 then%>
首页 上一页
<%else%>
<a href="<%=filename%>?page=1">首页</a>
<a href="<%=filename%>?page=<%=CurrentPage-1%>">上一页</a>
<%
end if
if n-currentpage<1 then
%>
下一页 末页
<%else%>
<a href="<%=filename%>?page=<%=CurrentPage+1%>">下一页</a>
<a href="<%=filename%>?page=<%=n%>">末页</a>
<%end if%>
页次:<strong><font color="#ff0000"><%=CurrentPage%>/<%=n%></font></strong>页
</div>
<%
end function
%>
<html>
<head>
<title>控制面板</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.STYLE2 {
color: #215DC6;
font-weight: bold;
font-size: 14px;
}
#tb1 {
border: 1px solid #0000FF;
padding: 1px;
font-family: "宋体", Arial;
font-size: 12px;
margin: 1px;
}
.STYLE3 {color: #FF6600}
.STYLE4 {color: #FF0000}
-->
</style>
</head>
<body><table align="center" width="100%" border="0">
<tr align="center">
<td height="80" align="center"><br>
<br>
<br>
<span class="STYLE2">文章管理中心</span><br>
<table width="671" id=tb1>
<tr>
<td width="30" align="center" id=tb1>ID</td>
<td width="340" align="center" id=tb1>标题</td>
<td width="99" align="center" id=tb1>作者 </td>
<td width="80" align="center" id=tb1>时间 </td>
<td width="100" align="center" id=tb1>管理项目 </td>
</tr>
</table>
<table width="671" border="0" id=tb1>
<%
if rseof=1 then
%>
<tr>
<td align="center" class="table00">没有任何文章</td>
</tr>
<%
else
if currentPage=1 then
showContent
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
else
currentPage=1
showContent
end if
end if
end if
%>
<% if rseof<>1 then
%>
<tr>
<td align="right" class="table00" colspan="5">
<%
showpage totalput,MaxPerPage,PageUrl
%>
</td>
</tr>
<%
end if
%>
</table>
</td>
</tr>
</table>
</body>
</html>
热心网友
时间:2024-10-28 16:25
ASP.NET 2.0中的页面输出缓存
参考资料:http://dotnet.chinaitlab.com/ASPNET/395231.html