Seven methods of implementing pagination display in ASP

Source: Internet
Author: User
Tags mdb database new features object model access database

Seven ways to implement pagination display in MS Visual InterDev6.0 when compiling web pages related to a database, we often face a problem of paging the data records because of the large amount of data to display.

--------------------------------------------------------------------------------
When you make ADO access to the database, the paging display, in fact, is the record of the recordset to operate. So we first have to understand the properties and methods of the Reordset object:
BOF attribute: Current indicator refers to the first pen in the RecordSet.
EOF attribute: The current indicator refers to the last stroke of the RecordSet.
Move method: Moves the metric to a record in the recordset.
AbsolutePage Property: Sets the location of the current record in which page
AbsolutePosition property: The position of the current indicator in the RecordSet.
PageCount property: Displays data about how many "pages" the Recordset object includes.
PageSize Property: Displays the number of records displayed on each page of the Recordset object.
RecordCount Property: Displays the total number of Recordset object records.
--------------------------------------------------------------------------------
In Microsoft's ASP programming system, the establishment of ADO object makes it easy to access database from Web page, especially ADO Recordset object makes the output of control data display more convenient and free. In Visual InterDev6.0 (hereinafter referred to as VI6.0), because of the script Object Model (SOM), design-time Control (hereinafter referred to as DTC), and Data Environment Object Model (hereinafter referred to as DEOM), such as the introduction of such objects, so that the Web page access to the database design seems more convenient.
For the purposes of the subject, for the connection to the database, only code and brief comments are given below, focusing on how the Recordset object (or control) can be used to implement the paging display of data records. As I understand it, the key to paging display is the mastery of the properties and methods of the Recordset control of the ADO Recordset object or DTC (design-time control).
The seven ways of paging are summed up in four categories:
The first to second kind I temporarily named "Pure ASP Method", this is also the domestic ASP website uses the most method, their difference only in realizes the skill difference. The implementation of these two methods is the easiest to understand, the object concept is the least, the development environment is the minimum requirements (as long as Notepad). It can be said that the essence of these two methods or CGI programming ideas, but only in the program to introduce the ADO object.
The fourth to fifth kind is called "Som's DHTML Method". Both of these methods require the Scripting object model proposed by Microsoft in the context of VI6.0 (script objects Model) and the new features of the database binding to the Table object in DHTML (many books and articles only introduce the use of DHTML CSS features in style design without introducing their data-binding characteristics), and enable the paging on the client control. However, it requires that the user's browser must support DHTML, such as Microsoft Internet Explorer version 4.0 and above.
The sixth kind is named "Som server-side method". Required to be developed in a VI6.0 environment, it utilizes several DTC controls in the Scripting object model presented by Microsoft: Recordset, PageObject, grid, and so on on the server side (the client) to achieve page control. This is an exciting, new programming approach that looks at web pages as objects (this object model differs from traditional DOM----Document Object models: The DOM can only control the client, while the SOM controls the server side and the client), It truly implements the Object-oriented programming of the Web page. But unfortunately, perhaps my personal ability is limited, this kind of technology I personally think is not very mature, for example, the combination with the browser is not very good, this will be detailed in the later text.
The seventh kind of temporary name is called "Deom Law". It also builds the Recordset object using the Data Environment Object Model (VI6.0) established in the environment. This is also a relatively rare new method of Web programming, compared to the SOM model, has its own advantages, which will be described in detail later.
In the following all examples of the source code, can be directly copied to use, you can not even understand its principle, as long as the Bold italic character part of the corresponding to their own database name or field name on it.

Before we begin to detail the various paging methods, let's create a database: Create a employee.mdb with access in Office97, build a table EMP, set only three fields: EMP id,last name and first name. Why this is so simple, because we care about how to deal with the results of the recordset.
First: The direct generation of parameters.
This is done by manually creating the Recordset object, using its pagesize (specify the number of records to be displayed per page), PageCount (total number of pages), and the AbsolutePage (current page number) property to control the paging output. Pagination uses the

The

<%//establishes a connection to the Employee.mdb database.
Set conn = Server.CreateObject ("ADODB. Connection ")
Conn. Open driver={microsoft Access Driver (*.mdb)};d bq=employee.mdb
//Create a Recordset object instance RS for the EMP table.
Set rs = Server.CreateObject ("ADODB.") Recordset ")
Rs. Open "EMP", Conn, 3

The

PageSize =//pagesize property specifies the number of record bars to display per page
page = CLng (Request ("Page") string converts to Long
If page < 1 Then page = 1
If Page > Rs. PageCount Then Page = Rs. PageCount
If Page <> 1 Then
Response.Write "<a href=emp1.asp? Page=1> first page </a> "
Response.Write" <a href=emp1.asp? Page= "& (Page-1) &" > Previous page </a> "
End If
if Page <> Rs. PageCount Then
Response.Write "<a href=emp1.asp? Page= "& (page+1) &" > Next page </a> "
Response.Write" <a href=emp1.asp? Page= "&rs. PageCount & "> Last </a>"
End If
Response.Write "page: & Page &"/"& Rs. PageCount & "</font>"
//per page display
///Show Header
Response.Write "<center><table border=1>"
Response.Write "<TR><TD>" & Rs. Fields ("emp ID"). Name & "</TD>" &NBSP;

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.