我写的一个常用的分页函数
调用<%=FerPage(0,0,"tbName="&tbName&"&",Rs.RecordCount,Rs.PageCount,Rs.PageSize,Ipage)%>
其它部分代码简单示例:
Rs.Pagesize = 20
Ipage = Request("page")
If Cint(Request("page")) <= 0 Then Ipage = 1
If Cint(Request("page")) > Rs.PageCount Then Ipage = Rs.PageCount
Rs.AbsolutePage = Ipage
For i = 1 To Rs.PageSize
If Rs.Eof Then Exit For
'********************************************************************
'*************************分页函数参数说明***************************
'--------pageinfo
是否显示分页信息,0为显示,1为不显示---------
'--------pageform
是否显示转到页面,0为显示,1为不显示---------
'--------parame
提交页面详细url,需带参数--------------------
'--------TotalCount
总记录数-------------------------------------
'--------PaperCount
页数-----------------------------------------
'--------PaperSize
每页显示数量---------------------------------
'--------CurrPaper
当前页数-------------------------------------
'********************************************************************
Function FerPage(pageinfo,pageform,parame,TotalCount,PaperCount,PaperSize,CurrPaper)
Dim myPath
myPath = Request.ServerVariables("PATH_INFO") & "?"
If pageinfo = "" Then pageinfo = 0
If pageform = "" Then pageform = 0
If IsNull(parame) Then parame = ""
FerPage = "<table width=""90%""
border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"" id=FerPage>" & vbCrlf
FerPage = FerPage & "<form name=""page"" method=""post"" action="""&myPath¶me&""">" & vbCrlf
FerPage = FerPage & "<tr><td align=""center"">" & vbCrlf
If pageinfo = 0 Then FerPage = FerPage & "共"&TotalCount&"条记录,分"&PaperCount&"页显示,每页显示"&PaperSize&"条,当前是第"&CurrPaper&"页" & vbCrlf
FerPage = FerPage & "<a href="""&myPath¶me&"page=1"">首 页</a>" & vbCrlf
If Cint(CurrPaper) <= 1 Then
FerPage = FerPage & "上一页 "&vbCrlf
Else
FerPage = FerPage & "<a href="""&myPath¶me&"page="&CurrPaper-1&""">上一页</a> "&vbCrlf
End If
If Cint(CurrPaper) >= Cint(PaperCount) Then
FerPage = FerPage & "下一页 " & vbCrlf
Else
FerPage = FerPage & "<a href="""&myPath¶me&"page="&CurrPaper+1&""">下一页</a> "&vbCrlf
End If
FerPage = FerPage & "<a href="""&myPath¶me&"page="&PaperCount&""">尾 页</a>"&vbCrlf
If pageform = 0 Then FerPage = FerPage & "跳转到:<input name=""page"" type=""text"" id=""page"" style=""border:inherit; border-style:solid; border-width:1px; border-color:#333333;"" size=""2"">页" & vbCrlf
FerPage = FerPage & "</td></tr></form></table>" & vbCrlf
End Function