Implementation of pagination display with ASP

Source: Internet
Author: User
Tags exit dsn sql query table name trim
I. Table structure definition:
 

----Table Name: Product


----Table Name: Product

----Field Name: Product No.: PRODUCT_ID

----Product Name: Product_Name



Two. Function Description:
 

----User enter a product number, you do not need to enter a full name. Fuzzy Query method. Find a record that satisfies the criteria.


----User enter a product number, you do not need to enter a full name. Fuzzy Query method. Find a record that satisfies the criteria.



Three. Program Script
 

----The entire program has three ASP files (omitting the HTML language section)


----The entire program has three ASP files (omitting the HTML language section)

----1 user query data entry form: input. Asp




-----User Input Product number
< Form method= "Post" action= "/cgi/prod.asp" >
< Input type= "Text" name= "Id" size= ">
< Input type= "Submit"
Value= "Submit" name= "B1" >
</form >

2. One of the paging processing procedures: prod.asp
Trigger----user submits form input.asp

<%cid=trim (Request.Form ("Id")% >

<%set RLT = CreateObject ("Adodb.recordset")% >
Creating a Recordset object
<%sql= "Select * from Product Where product_id like '
"& Cid &" ' + '% ' ">

<%rlt.open Sql, "uid=ncgi; pwd=sql;dsn=tcgi ", 1% >
Execute SQL statement

<% If rlt.pagecount< 1 Then% >
< H2 > No record </H2 >
< A href= "Javascript:History.Back ()" >
Back < a >
<%else% >

-------------------North Star Stacks | | Http://www.ebook007.com
The following display query information: Display style:
Total xx page XXX Records page No.: 1.2.3. 4.5...

Total <%=rlt.pagecount% > page
<%=rlt.recordcount% > Records

Page number:<% I=1 to rlt.pagecount% >
<%CID=RLT ("product_id")
< ahref= "Prodpage.asp?" pcnt=<%=i% >&id=<%=cid% > >
<%=i% >.</a >
<%next% >
< a >
< Hr >
<%rlt.pagesize=20% >
The following display product list: Display style:
1.XXXX
2.XXXX
****** ...........

<%rlt.absolutepage=1% >
<% for I=1 to rlt.pagesize% >
<% If Rlt.eof Then
Exit for
End if% >
< Li ><%=i%. <%=trim (RLT ("Product_Name")) </li >
<%rlt.movenext
next% >
<%rlt.close% >

3. Paging Process two: propage.asp

----User Selection (page number: 1.2.3.) 4.5.......) Trigger after a page number in

<%cid=trim (Request.QueryString ("Id")% >
<%rlt.absolutepage=request.querystring ("pcnt")% >

The above part is identical with prod.asp * * *

<% for I=1 to rlt.pagesize% >
<% If Rlt.eof Then
Exit for
End if% >
< Li ><%=i%. <%=trim (RLT ("Product_Name")) </li >
<%rlt.movenext
next% >
<%rlt.close% >



Four. Supplementary notes;
 

----You can have the user set the length of each page. The method is to use the session object to maintain user information to accept user settings information:


----You can have the user set the length of each page. The method is to use the session object to maintain user information to accept user settings information:



<%session ("size") =request.form ("size")% >

Replace the prod.asp <%rlt.pagesize=20% > sentence with the following statement
<%if session ("size") = "" Then
Rlt.pagesize=20
Else
Rlt.pagesize=session ("size")
End if% >

Difficult to resolve

1. The key to paging function:
Application of Pagesize AbsolutePage attribute
Pagesize: per page record size
AbsolutePage: The cursor navigates to that page. For example, there are 20 records, divided into two pages, each page 10
Absolutepage=1 begins with the first record.
The absolutepage=2 begins with the 11th record.
2.<%rlt.open Sql, "uid=ncgi; pwd=sql;dsn=tcgi ", 1% >
DSN: System Data Source Name, Uid: User name, PWD: User password, 1: Cursor type

You must be in the Control Panel-->
Set up system data source in 32-bit ODBC, remember the system data source
Rather than a user data source
Cursor Type: 0, is the default value, but if you want to implement the paging function the cursor type must be set to 1
Otherwise Recordcount Pagesize PageCount properties are not available.

3.request.form ("id") and request.querystring ("id")

The name is ID
Request.QueryString ("id") refers to accepting data from a URL



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.