Saturday, February 7, 2009
Wednesday, January 28, 2009
Displaying database records involves retrieving information stored in a database or other source of content, and rendering that information to a web page. Macromedia Dreamweaver 8 provides many methods of displaying dynamic content, and provides several built-in server behaviors that let you both enhance the presentation of dynamic content, and allow users to more easily search through and navigate information returned from a database.
This chapter contains the following sections:
About displaying database records
Creating recordset navigation links
Showing and hiding regions based on recordset results
Displaying multiple recordset results
Databases and other sources of dynamic content provide you with more power and flexibility in searching, sorting, and viewing large stores of information. Using a database to store content for web sites makes sense when you need to store large amounts of information, and then retrieve and display that information in a meaningful way. Dreamweaver provides you with several tools and prebuilt behaviors to help you effectively retrieve and display information stored in a database. The following sections describe the Dreamweaver server behaviors and formatting elements, and how you can use them to display dynamic content.
This section covers the following conceptual topics:
Dreamweaver provides the following server behaviors and formatting elements to let you enhance the display of dynamic data:
Formats let you apply different types of numerical, monetary, date/time, and percentage values to dynamic text.
For example, if the price of an item in a recordset reads 10.989, you can display the price on the page as $10.99 by selecting the Dreamweaver "Currency - 2 Decimal Places" format. This format displays a number using two decimal places. If the number has more than two decimal places, the data format rounds the number to the closest decimal. If the number has no decimal places, the data format adds a decimal point and two zeros.
Repeated Region server behaviors let you display multiple items returned from a database query, and let you specify the number of records to display per page.
Recordset Navigation server behaviors let you insert navigation elements that allow users to move to the next or previous set of records returned by the recordset. For example, if you choose to display 10 records per page using the Repeated Region server object, and the recordset returns 40 records, you can navigate through the records 10 at a time.
Recordset Status Bar server behaviors let you include a counter that shows users where they are within a set of records relative to the total number of records returned.
Show Region server behaviors let you choose to show or hide items on the page based on the relevance of the currently displayed records. For example, if a user has navigated to the last record in a recordset, you can hide the "next" link, and display only the "previous" records link.
A powerful feature of Dreamweaver is the ability to present dynamic data within a structured page, and to apply typographic formatting using HTML and CSS. To apply formats to dynamic data in Dreamweaver, format the tables and placeholders for the dynamic data using the Dreamweaver formatting tools. When the data is inserted from its data source, it will automatically adopt the font, paragraph, and table formatting you specified.
To learn about Dreamweaver formatting features, and how to apply them to dynamic data elements, see Presenting Content with Tables and Inserting and Formatting Text.
Recordset navigation links let users move from one record to the next, or from one set of records to the next. For example, after designing a page to display five records at a time, you might want to add links such as "Next" or "Previous" that let users display the five next or previous records.
Dreamweaver lets you create four types of navigation links to move through a recordset: First, Previous, Next, and Last. A single page can contain any number of these links, provided they all work on a single recordset. You can’t add links to move through a second recordset on the same page.
NOTE |
| Microsoft ASP.NET refers to a recordset as a DataSet. If you are working with ASP.NET document types, the dialog boxes and menu choices specific to ASP.NET use the label DataSet. The Dreamweaver documentation generically refers to both types as recordsets, but uses DataSet when specifically describing ASP.NET features. |
Recordset navigation links require the following dynamic elements:
- A recordset to navigate
- Dynamic content on the page to display the record or records
- Text or images on the page to serve as a clickable navigation bar
- A "Move To Record" set of server behaviors to navigate the recordset
You can add the last two elements using the Record Navigation Bar server object, or you can add them separately using the Dreamweaver design tools and the Server Behaviors panel.
If you want to create a recordset navigation bar that uses more complex layout and formatting styles than the simple table created by the Recordset Navigation Bar server object, you might prefer to create your own navigation bar. To do this, you must first create the necessary navigation links in either text or images, place them within the page in Design view, and assign individual server behaviors to each navigation link.
You can assign the following individual server behaviors to navigation links:
- Move to first page
- Move to last page
- Move to next page
- Move to previous page
If you would prefer to use the Dreamweaver built-in Recordset Navigation Bar server object to create a navigation bar, see Creating a navigation bar using the Recordset Navigation Bar server behavior.