Implementation of paging Display for ASP recordsets

Source: Internet
Author: User
Tags empty
We all know that in the dreamwerver can be easily implemented in the recordset's paging display, but the generated code is very large, affecting the speed of the Web page display, it does not look very clear, then, can the simple way to achieve the same function? Of course, the author through the following simple code to achieve the recordset's paging display, now come out and share.

The main code is as follows:
<%
If Rs1.recordcount>0 Then ' Recordset is not empty processing records
Rs1.pagesize = 10 ' Sets the number of records to display per page
Num=rs1.recordcount ' Total records
Pagenum=rs1.pagecount ' page totals
Page=request ("page") ' Get the original information of the page number
' Process the beginning of the page number raw information!
If page <> "Then
page = CInt (page)
If Err.Number <> 0 Then
Err.Clear
page = 1
End If
If page 1 Then
page = 1
End If
Else
page = 1
End If
If page*rs1.pagesize > num and not ((page-1) *rs1.pagesize num) Then
Page=1
End If
' Handle the end of the page number raw information! Set Current page number
Rs1.absolutepage = page
%>
!--to determine whether the current page is the last page and to set the duplicate display of the record according to the judgment-->
<% if page <> pagenum then
Lablenum=rs1.pagesize
Else
lablenum=num-(page-1) *rs1.pagesize
End If
For I=1 to Lablenum
%>
<TR bgcolor= "#FFFFFF" >
<TD height= "><div" align= "center" ><%= (rs1. Fields.item ("id"). Value)%> </div> </td>
The <td> <div align= "center" ><%= (rs1. Fields.item ("name"). Value)%> </div> </td>
The <td> <div align= "center" ><%= (rs1. Fields.item ("Address"). Value)%> </div> </td>
The <td> <div align= "center" ><%= (rs1. Fields.item ("category"). Value)%> </div> </td>
The <td> <div align= "center" ><%= (rs1. Fields.item ("Last Modified"). Value)%> </div> </td>
The <td> <div align= "center" ><%= (rs1. Fields.item ("Modified person"). Value)%> </div> </td>
</tr>
<%
Rs1.movenext
Next
%>
!--the record for the current page is displayed, the following code is--> the recordset pagination link code
<table width= "70%" border= "0" align= "center" cellpadding= "0" cellspacing= "0"
<tr>
<TD height= "35" >
<div align= "Right"
<font color= "#333333" >
A total of <%=num%> links |
<a href=linkadmin.asp?page=1> Home </a> |
<%if page>1 then%><a href=linkadmin.asp?page= <%=page-1%> ><%end if%> prev </a> |
<%if page<pagenum then%><a href=linkadmin.asp?page= <%=page+1%> ><%end if%> Next </a> |
<a Href=linkadmin.asp?page= <%=pagenum%> > last </a> |
Page times: <%=page%>/<%=pagenum%> Page |
Total <%=pagenum%> Page
</font>
</div>
</td>
</tr>
</table>
!--recordset pagination Link code ends and the recordset is empty to execute the following code-->
<%else%>
<TR bgcolor= "#FFFFFF" >
<TD height= colspan= "6" ><div align= "center" ><% response. Write ("No results to show!") ")%>
</div> </td>
</tr>
<%
End If
Rs1. Close ()
Set rs1 = Nothing
%>
All right, it's easy! As long as a simple change can be inserted into your Web page to display the record place, quickly try it!
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.