Dreamweaver MX Ultradev Exploration (2)

Source: Internet
Author: User
Tags object insert return dreamweaver
Dreamweaver Dreamweaver MX Ultradev Exploration (2) displaying records in a database

In the last lecture, we mainly talked about setting up the database connection, today we want to start the real implementation of the background application, from the database to get the data, the previous talk is for today's work to prepare. Now we see the Web page is basically dynamic, the so-called dynamic is the combination of the database, automatic update information. Retrieving data from a database is one of the most basic, and also a dynamic way we use most often. Below we will search through the product table in the Northwind database to retrieve a list of products information.

Note If you set up your site, access in the testing server option is set to FTP or local/network (Figure 2-1), or bindings is not available.

Figure 2-1

Select the bindings label in the application panel on the right. Press the plus button (Figure 2-2)

Figure 2-2
In the recordset dialog box, set the details as follows:

Connection:northwind (That's the connection we set up in the last lecture, we can choose)
Table:product (all tables in the database are listed here, we select Product)
Columns: The inside is all the fields in product, and if you select the Select radio button, then we can filter the fields. (Figure 2-3)

Figure 2-3

After setting up, we can test, press the right test button, is not very surprised, we need data has been all listed, the power of the tool is great! (Figure 2-4)

Figure 2-4
Click OK to go back to the Recordset dialog box and click OK to return to the page, when we can see the changes in the binding tag, we have established a query called Disproduct appears. I think we see this should be very easy to think of the object, very intuitive it, than in the code to establish the object is easy to understand a lot of it (Figure 2-5) Click Next to the "+" number, expand, the Product table all the fields appear in front of you. (Figure 2-6)

Figure 2-5

Figure 2-6

Our goal is to display a product list on the page, and you will find it easy to show what's in the database on the page, and you'll feel the greatness of the tool again.
Create a two-row four-column table on the page, in the first line: Product name, number of units, Unit price, inventory (Figure 2-7) These are the fields that we want to display on the page. In the next section, we'll put the contents of the field in.

Figure 2-7

Select the field to expand in bindings, we first select the "Product Name" field, and then click the mouse in the second row of the table, make the cursor blink, then go back to the Bindings panel and click the Insert button (Figure 2-8)

Figure 2-8
In turn, insert the "unit quantity, Unit price, inventory" field into the table in the same way (figure 2-9), and there's a simpler way that you can drag the field to the place where it will be placed, the effect is the same, and it's simpler. OK, now look at the original code, if you are a beginner of ASP, tell you an experience, is to see more MX generated by the original code, for you to learn ASP is a great help. Because you will find that you can simply add a few lines of code to try two pages together, such as the login page, it is something, slowly watching you will know.

Figure 2-9

OK, now save your page and look at the results of your work in the browser. Please don't tell me you don't know how to debug the ASP page! show how, only a row of results, is not very let you down ah. Haha, the record pointer does not move, but only the first line is displayed. Then look.

We are going to start talking about the server behaviors, use her to achieve a lot of functions, not to say, slowly see, we now want to solve the problem is how to display all the records. Select all cells in the second row of the table (Figure 2-10),

Figure 2-10
Click the "+" button on the Server Behaviors tab, select Repeat Region in the Drop-down menu, select the All radio button in the Repeat Region dialog box, or select the radio button above if you don't want to show all of them. Enter the number you want to display (Figure 2-11)

Figure 2-11

Press the OK button to return. One more behavior appears in the Server Behaviors tab (Figure 2-12). Looking at the original code, you find that he just added a loop statement.

Figure 2-12

Save the changes and debug again, how much you set in (Figure 2-11). Today to this position, we can review the following, mainly to build inquiries, there are many tips.


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.