Detailed explanation of pagination display with ASP

Source: Internet
Author: User
Tags exit dsn query table name trim
Paging | show

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, do not need to enter a full name. A fuzzy Query method is used. Find the record that satisfies the condition.----User Enter the product number without entering the full name. Fuzzy Query method. To the record that satisfies the condition.

  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")% > Hu Jintao Create a Recordset object

<%sql= "Select * from Product Where product_id like '" & Cid & "' + '% '" >

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

<% If rlt.pagecount< 1 Then% >

< H2 > No record </H2 >

< A href= "Javascript:History.Back ()" > Back to </A >

<%else% >

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 shows the 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")% > above part and prod.asp same * * * * * *

<% 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 Note:

----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 let users 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 <%if session with the following statements ("size") = "then rlt.pagesize=20 else rlt.pagesize=" in prod.asp <%rlt.pagesize=20% > Session (' Size ') end if% >

  difficult to resolve

1. Key to paging: Pagesize AbsolutePage Property Application Pagesize: Per-page record size AbsolutePage: The cursor is positioned to that page. For example, there are 20 records, two pages, 10 strips per page 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: username, Pwd: User password, 1: Cursor type you must establish a system data source in the Control Panel-> 32-bit ODBC, and remember that it is a system data source, not a user data source cursor type: 0 , is the default value, but if you want to implement paging functionality the cursor type must be set to 1 otherwise Recordcount Pagesize PageCount properties are not available.

The name of the 3.request.form ("id") and request.querystring ("id") is the ID request.querystring ("id") that accepts data from the 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.