Detail Page(Cont.) - Page 14
August 7,2002
Now, in your document create a table with two rows and
two columns. Place your cursor in the second row of the left column, and choose
Image from the Insert
menu – the following dialog box shall appear:
As seen above, click the Data Sources radio button from the top. You
will see all the recordsets you created for this particular page – there should
only be one currently – rsBooks.
Expand the tree for this recordset, and select the database column that holds
the URL path to the image – book_image_path. Hit OK.
Dreamweaver MX will place an image placeholder for the dynamic
image on your page. When the page is viewed live, the appropriate image will
appear.
Next, place your cursor in the second row of the right-hand
column. From Bindings, drag and drop
book_title, book_author_fname, book_author_lname, and book_price into the column, format the text as you like.
Highlight book_price on your page, then in Bindings
you should see this field highlighted. Click the upside-down arrow to the
right of it and you will see some formatting options (you may have to scroll
the Application panel to the far right to see it)
like so:
Select Currency
> Default. This will format the
text to display as currency, using a VBScript built-in function. (See Chapter 5 for a refresher on VBScript built-in
functions.)
Lastly we need to add a repeat region so that all the records
will display. Repeat the second row of your table by selecting the entire
second row of the table, selecting <tr> from the status bar of the Dreamweaver MX document, and selecting
Server Behaviors > Repeat Region. Choose the rsBooks recordset from the recordset menu and display all the records. Hit
OK. You might also want to add a link back
to the master page somewhere on your detail page.
Load the categories3.asp page in your browser and click the Genre Fiction link – you should be taken to
the detail page (books.asp) and it should
display a list of the books associated with that category (ours looks like
this):
Isn't that cool? You didn't have to manually create that
long list of books with static HTML and update it manually – ASP generates
the HTML for you, and Dreamweaver MX generates the ASP for you! All you have
to do now to display new information through your web application is to add
new records to your books table.
You can manually add a record to the database in Access, or you could
create an online content management system for yourself to make it easier
to update your records at any time. You will learn more about this kind of
extension in the sections on the Insert, Update, and Delete behaviors later
in this chapter.
Some of our categories have no books under them at the moment,
for example the World Literature category, so when you click on it, the books.asp page will
be empty. We are be able to make this page more user-friendly for recordsets
that come up empty by utilizing the Show
If Recordset Is Empty server behavior. We will deal with this server
behavior in the Show Region section, but before we get to this let's play
with this page even more using some other cool server behaviors!
Detail Page - Page 13
Dynamic Dreamweaver MX
Recordset Paging - Page 15
|