ASP. NET method for processing data paging in browsers (1)

Source: Internet
Author: User

When programming ASP databases, due to browser size restrictions, when there are many data records to be browsed, in order to achieve more intuitive results, we divide these data records into several pages and use the data navigation buttons or other hyperlinks) to browse through pages. In fact, the paging browsing of such data records can also be implemented in ASP. NET. In addition, the implementation process is clearer and easier than the ASP processing process.

There are two basic types of browser-based paging data records. Other types of page views can be either modified or integrated. The following figure shows the specific expression:


Figure 01: Data Record pattern browsing by PAGE


Figure 02: Second paging data record Style

The following describes how to implement these two types of paging data records in ASP. NET:

First, let's introduce the database we use. In this article, we use the local database Access 2000 and the database name is "Data. mdb, which stores a data table "tblItem ". The structure of this data table is as follows:

Field name Field Type
ItemID Automatic ID
ItemName Text Type

If you are using another database, simply modify the program described below. This will be introduced below.

I. software environment for program design and operation in this article:

1). Microsoft Windows 2000 Server Edition

2). Net FrameWork SDK Beta 2

II. Key Steps and implementation methods of the first paging data record:

1) first, you must obtain the hyperlink string of the initial browsing data record:

This is actually very important, because operations such as "Homepage" and "next page" in the first type of page view are implemented by adding parameters of the page to be browsed after the hyperlink string, the program in this article is implemented through the GetPageName () function. This function is as follows:

Function GetPageName () As String
Dim Str As String
Dim Pos As Short
Str = Request. ServerVariables ("Script_Name"). Trim ()
Pos = Str. LastIndexOf ("/")
If Pos> = 0 Then
Return Str. SubString (Pos + 1)
Else
Return Str
End If
End Function

2). Obtain the total number of data records you want to browse:

In this article, we use all the records in the data table "tblItem" for viewing convenience. The ASP. NET page uses ADO. NET to obtain the data table "tblItem ". The following code uses ADO. NET to obtain the total number of records in the tblItm table:

<% @ Page Language = "VB" %>
<% @ Import Namespace = "System. Data" %>
<% @ Import Namespace = "System. Data. OleDb" %>


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.