日期:2014-05-17  浏览次数:20796 次

怎样在ASP中对记录分页显示?
<%
        Dim   Sql,Rs,j
        Set   Rs=Server.CreateObject( "ADODB.RecordSet ")
                        Sql= "Select   *   From   news   where   class=1   and   tjnews=1   Order   By   Id   Desc "
                        Rs.Open   Sql,Conn,1,3
        RsCount=Rs.RecordCount
%>
<%
for   j=1   to   RsCount
%>
        <table   width= "100% "   border= "0 "   cellpadding= "0 "   cellspacing= "0 "   bgcolor= "#FAFAFA ">
        <tr   style= "height:25px ">
            <td   width= "10% "> &nbsp; </td>
<td   width= "75% "   style= "FONT-SIZE:   12px;   LINE-HEIGHT:   180% "> · <a   href= " <%=Rs( "FilePath ")%> <%=Rs( "FileName ")%> "   target= "_blank " "> <font   color= "red "> <%=Rs( "title ")%> </font> </a> </td>
        <td   width= "15% "   style= "FONT-SIZE:   12px;   LINE-HEIGHT:   180% "> <font   color= "#999999 "> <%=year(Rs( "addtime "))%> - <%=month(Rs( "addtime "))%> - <%=day(Rs( "addtime "))%> </font> </td>
</tr>
        <tr> <td   bgcolor= "#EAEAEA "   colspan= "3 "   height= "1 "> </td> </tr>
        </table>
<%
Rs.movenext
next
%>
<%
Rs.close
set   Rs=Nothing
%>
现在我想在这基础上实现每页显示20条记录,多余的就分页显示,分页效果如下:
首页   上一页   下一页   末页   输入某页回车就到某页
该如何实现?

------解决方案--------------------
'******************************************************************************************************************
'分页器
Function PageBreak(Record,PageNum,ByVal RecordMax,ByVal Action,ByVal Hidden)

Dim PageTemp,i,MaxPage

PageBreak = " "

if Record = " " then
Record = 15
else
if IsNumeric(Record) then
Record = cint(Record)
else
Record = 15
end if
end if
if Record > RecordMax then
Record = RecordMax
end if
if Record < 1 then
Record = 1
end if

MaxPage = RecordMax \ Record
IF (RecordMax Mod Record)> 0 Then
MaxPage = MaxPage + 1
End If

if PageNum = " " then
PageNum = 1
else
PageNum = cint(PageNum)
end if

if PageNum > MaxPage then PageNum = MaxPage
if PageNum < 1 then PageNum = 1

PageBreak = PageBreak & " <form method= " "get " " action= " " " & Action & " " "> "
PageBreak = PageBreak & Hidden

PageBreak = PageBreak & " <div style= " "float