Rookie 10 days Learn ASP Tutorial Day: Paging Technology

Source: Internet
Author: User
Tags definition contains mdb database modify variable
Pagination | tutorials | 10 Day Society

Previous section: SessionComponent

  Learning purposes: Paging technology

The last day of today we learn a little bit more difficult in the ASP page paging technology, after all, when we have n records when we can not put all the records in a page inside it.

<%
Exec= "SELECT * FROM Test"
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open exec,conn,1,1
Rs. Pagesize=3
Pagecount=rs. PageCount
Page=int (Request. QueryString ("page"))
If Page<=0 then page=1
If request. QueryString ("page") = "" Then page=1
Rs. Absolutepage=page
%>

Rs.pagesize set a page to display the number of records, PageCount is our own definition of a variable, Rs.pagecount is the number of records, page is our own definition of a variable, our next page of the link can be set to list.asp? Page=<%=page+1%>, the next page of the link can be set to List.asp?page=<%=page-1%>, so that when the link is pressed to call the page itself, page this variable is +1 or 1, Finally we let rs.absolutepage (the current page) as page page on it.

If request. QueryString ("page") = "" Then page=1, the function of this sentence is that we open the list.asp when we do not follow the page variable, automatically set to page=1, to prevent errors, and when we if....then ... The end if can be omitted when placed on a line. is paging not difficult?

Here's a special case:

If page=1 and not page=pagecount, there is no previous page at this time, but there is a next page
ElseIf Page=pagecount and not page=1, this time there is no next page, but there is a previous page
ElseIf page<1, there's no record at this time.
ElseIf Page>pagecount Then, there's no record at this time.
ElseIf page=1 and Page=pagecount, this time there is no previous page, no next page
Else, this time there is a previous page, also has the next page.

The following section shows 1 to n pages, and each number after clicking on the number of pages represented in the code, very common OH.

<%for I=1 to Pagecount%>
<a href= "List.asp?page=<%=i%>" ><%=i%></a><%next%>

For....next is the cycle starting at I=1, and the cycle is added 1 to PageCount.

Finally, my example contains a simple ASP program, but the function of everything, is the essence of ASP, every ASP large program contains it.

add.htm Add Record page
add.asp Increase record operation
Conn.asp Database Links
del.asp Delete Record operation
Modify.asp Modify Record page
Modifysave.asp Modify record operations
List.asp This is the core of this program, through this page to achieve the record add, modify, delete.
Test.mdb database, which has aa,bb two fields:AA Numeric type can only accept numbers , BB is character type.

Finally, I would like to say that this example is the essence of ASP, we must study hard, understand the program, you will find that you have an ASP. finally to provide you with a source program, click here to download

The end of the tutorial, I hope you continue to pay attention to this site! Support this site, help the site publicity!! Thank you, hope to have the ability of a friend of mine above the tutorial or the site to achieve the tutorial video tutorials! Thank you! Our web site is http://www.webjx.com.



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.