主题:  求ASP记录集翻页程序,急啊!!!

shiqiong

职务:普通成员
等级:1
金币:0.0
发贴:34
#12004/8/11 14:07:03
怎样在DW里做翻页啊?就是记录集导航条,怎么做啊???
请知道的高人指点迷津.能否给我一份用ASP写的记录集分页的程序,我好学习借鉴一下.多谢!!!



绿茶

职务:普通成员
等级:8
金币:10.0
发贴:19267
#22004/8/11 15:07:46
...
set rs=server.createobject("adodb.recordset")
dim pagesize
pagesize=20 '===一页的记录数
page=request("page")
if page="" or not(isnumeric(page)) then
    page=1
end if

url="lawlist.asp"


rs.open sql,conn,1,1

if not rs.EOF then
    rs.PageSize=pagesize
    pagecount=rs.pagecount
    if int(page)>int(pagecount) then
         page=pagecount
    end if
    rs.AbsolutePage=page
    row=pagesize
end if%>
...
<%if not rs.eof then%>
<table border="0" width="99%">
<tr>
<td width="100%">
[<a href="<%=url%>?page=1" title="确定">首页</a>|
<%if int(page)<=1 then%>
上一页|<%
else%>                        
     <a href="<%=url%>?page=<%=page-1%>" title="确定">上一页</a>|
     <%end if%>
                    
     <%if int(page)>=int(pagecount) then%>
     下一页|<%
     else%>
        <a href="<%=url%>?page=<%=page+1%>" title="确定">下一页</a>|                        
     <%end if%>
     <a href="<%=url%>?page=<%=pagecount%>" title="确定">尾页</a>]    共 <%=pagecount%> 页,当前第
<font color="#FF0000"> <%=page%> </font> 页,计 <%=rs.recordcount%> 条记录
</td>
</tr>
</table>
<div align="center">
<center>
<table border="0" width="99%" cellspacing="1" cellpadding="0">
<tr>
<td width="4%" height="35" align="center" bgcolor="#6699FF"><font color="#FFFFFF"><b>序号</b></font></td>
<td width="31%" height="35" align="center" bgcolor="#6699FF"><font color="#FFFFFF"><b>标题</b></font></td>
<td width="55%" height="35" align="center" bgcolor="#6699FF"><font color="#FFFFFF"><b>内容</b></font></td>
<td width="10%" height="35" align="center" bgcolor="#6699FF"><font color="#FFFFFF"><b>操作</b></font></td>
</tr><%
i=0
do while not rs.eof and row>0
        i=i+(page-1)*row+1
            %>
<tr bgcolor="#E6F2FF" onmouseOver="mOvr(this,'#D5D2FB');" onmouseOut="mOut(this,'#E6F2FF');">
<td width="4%" height="25" align="center"><%=i%></td>
<td width="31%" height="25" align="left">&nbsp;<%=rs("title")%></td>
<td width="55%" height="25" align="left" valign="middle">&nbsp; <%=left(rs("content"),30)%>...</td>
<td width="10%" height="25" align="center"><font color="#FF0000"><a href="law.asp?id=<%=rs("id")%>"><font color="#FF0000">修改</font></a><font color="#FF0000">|</font><a href="law_del.asp?id=<%=rs("id")%>" onclick="return confirm('确定删除吗?');"><font color="#FF0000">删除</font></a></font></td>
</tr>    <%
row=row-1
     rs.movenext
     loop%>
</table>
</center>
</div>
<%else
%>
<table border="0" width="90%" height="80">
<tr>
<td width="100%" height="76">
<p align="center">暂无记录</p>
</td>
</tr>
</table>
<%end if%>
</center>

</body>

</html>
<%
conn.close
set conn=nothing%>