论坛: 网站建设 标题: 关于网页的分页技术! 复制本贴地址    
作者: boy_sc [boy_sc]    论坛用户   登录
有哪个会ASP的朋友,我这里遇到一点麻烦。就是ASP的分页,还请大家多多指点。谢谢。


地主 发表时间: 04-07-28 20:33

回复: imstone [imstone]   论坛用户   登录
Recordset对象的属性
Absolutepage
设置当前记录的绝对页号
rs.absolutepage=5 当前记录处于第5页。
AbsolutePosition
指出Recordset对象当前记录的顺序位置
rs.absolutePosition=5 当前记录处于第5条记录。
Bof
返回当前记录是否在首条记录之前,并返回布尔值。
表中无记录时Bof 为真值。
Eof
返回当前记录是否在尾记录之后,并返回布尔值。
当记录移到最后一条记录之后,Eof为真值。
PageCount
指明当前指针所包含的页数。
  PageSize
每页显示的记录数
rs.PageSize=10
PageSize PageCount AbsolutePage 是一组完整的搭配。
PageSize 决定一页的记录条数
PageCount 决定了共有多少页
AbsolutePage 指定了当前处于第几页

RecordCount
返回表内共有多少条记录
Recordset对象的方法
AddNew
描述:在一个可更新的Recordset对象内新增一条记录。
说明:在没有调用Update之前记录不会增加到表中。
Close
关闭一个Recordset对象及其相关的对象。
Rs.close
Delete
删除一条或一组记录。
Rs.delete
Move
移动指针
MoveFirst     移动到第一条记录
MoveLast   移动到最后一条记录
MoveNext   移动到下一条记录
MovePrevious  移动到上一条记录


B1层 发表时间: 04-07-29 20:43

回复: tommy_he [tommy_he]   版主   登录
<%
  const MaxPerPage=25
  dim sql
  dim rs
  dim totalPut 
  dim CurrentPage
  dim TotalPages
  dim i,j
%>
</head>
<body bgcolor=Thistle>
<P align=center><FONT face=方正舒体><FONT size=5><STRONG>
分页技术</STRONG>

<%
conn = "DBQ=" + server.mappath("mydb.mdb") + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
sql = "SELECT * FROM mytable"
set rs=server.createobject("adodb.recordset")
rs.open SQL,conn,1,1
rs.MoveFirst
rs.pagesize=MaxPerPage
howmanyfields=rs.Fields.Count-1

If trim(Request("Page"))<>"" then
CurrentPage= CLng(request("Page"))
If CurrentPage> rs.PageCount then
CurrentPage = rs.PageCount
End If
Else
CurrentPage= 1
End If

if rs.eof then
response.write "<p align='center'> ERROR!</p>"
else
totalPut=rs.recordcount
if CurrentPage<>1 then
if (currentPage-1)*MaxPerPage<totalPut then
rs.move(currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
end if
end if

dim n,k
if (totalPut mod MaxPerPage)=0 then 
n= totalPut \ MaxPerPage
else 
n= totalPut \ MaxPerPage + 1 
end if%>
</FONT></FONT></P>
<P>PAGE <%=currentpage%> OF <%=n%>  共<%=rs.recordcount%> 纪录
<% k=currentPage
if k<>1 then
response.write "[<b>"+"<a href='index.asp?page=1'>首页</a></b>] "
response.write "[<b>"+"<a href='index.asp?page="+cstr(k-1)+"'>上一页</a></b>] "
else
Response.Write "[首页] [上一页]"
end if
if k<>n then
response.write "[<b>"+"<a href='index.asp?page="+cstr(k+1)+"'>下一页</a></b>] "
response.write "[<b>"+"<a href='index.asp?page="+cstr(n)+"'>尾页</a></b>] "
else
Response.Write "[下一页] [尾页]"
end if
%>

</P>

<TABLE border=1 align=center>
<tr>
<%
for i= 0 to howmanyfields%>
<TD><B><%=rs(i).name%></B></TD>
<%
next
i=0
do while not rs.eof and i<maxperpage%>
<tr align=middle>
<%for j=0 to howmanyfields%>
<td>
&nbsp;<%=rs(j)%>&nbsp;
</td>
<%next%>
</tr>
<%
i=i+1
rs.movenext
loop
%>
</TABLE>
<%
end if
rs.close
set rs=nothing
%>
</body>
</html>

B2层 发表时间: 04-08-01 15:22

回复: poemail [poemail]   论坛用户   登录
好贴,顶一下,留给后生小子…………

B3层 发表时间: 06-10-20 15:41

回复: asusmlan2 [asusmlan2]   论坛用户   登录
分页,可以去下载个新闻系统下来研究一下嘛

B4层 发表时间: 06-10-20 19:42

回复: poemail [poemail]   论坛用户   登录
中黑同志,我是故意把两年前的帖子给翻出来,就是不想看到到处是你的大名,哪知你还是顶了上去,不简单哦……


B5层 发表时间: 06-10-21 11:47

论坛: 网站建设

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号