Dreamweaver

Create links to the detail page

After building the master page and adding the recordset, you create links that open the detail page. You then modify the links to pass the IDs of the records the user selects. The detail page uses this ID to find the requested record in the database and display it.

Note: You create links to update pages using the same process. The results page is similar to a master page, and the update page is similar to a detail page.

Open the detail page and pass a record ID (ColdFusion, PHP)

  1. In the dynamic table, select the content placeholder for text that will serve as a link.
    Links applied to placeholder selected.

  2. In the Property inspector, click the folder icon beside the Link box.
  3. Browse and select the detail page. The detail page appears in the Link box in the Property inspector.

    In the dynamic table, the selected text appears linked. When the page runs on the server, the link is applied to the text in every table row.

  4. On the master page, select the link in the dynamic table.

    If Live Data view is enabled, select the link in the first row.

  5. (ColdFusion) In the Link box in the Property inspector, add the following string at the end of the URL:
    ?recordID=#recordsetName.fieldName#

    The question mark tells the server that what follows is one or more URL parameters. The word recordID is the name of the URL parameter (you can make up any name you like). Make a note of the name of the URL parameter because you'll use it in the detail page later.

    The expression after the equal sign is the value of the parameter. In this case, the value is generated by a ColdFusion expression that returns a record ID from the recordset. A different ID is generated for each row in the dynamic table. In the ColdFusion expression, replace recordsetName with the name of your recordset, and replace fieldName with the name of the field in your recordset that uniquely identifies each record. In most cases, the field will consist of a record ID number. In the following example, the field consists of unique location codes.

    locationDetail.cfm?recordID=#rsLocations.CODE#

    When the page runs, the values of the recordset's CODE field are inserted in the corresponding rows in the dynamic table. For example, if the Canberra, Australia, rental location has the code CBR, the following URL is used in the Canberra row in the dynamic table:

    locationDetail.cfm?recordID=CBR
  6. (PHP) In the Link field in the Property inspector, add the following string at the end of the URL:
    ?recordID=<?php echo $row_recordsetName['fieldName']; ?>

    The question mark tells the server that what follows is one or more URL parameters. The word recordID is the name of the URL parameter (you can use any name you like). Make a note of the name of the URL parameter because you’ll use it in the detail page later.

    The expression after the equal sign is the value of the parameter. In this case, the value is generated by a PHP expression that returns a record ID from the recordset. A different ID is generated for each row in the dynamic table. In the PHP expression, replace recordsetName with the name of your recordset, and replace fieldName with the name of the field in your recordset that uniquely identifies each record. In most cases, the field will consist of a record ID number. In the following example, the field consists of unique location codes.

    locationDetail.php?recordID=<?php echo $row_rsLocations['CODE']; ?>

    When the page runs, the values of the recordset’s CODE field are inserted in the corresponding rows in the dynamic table. For example, if the Canberra, Australia, rental location has the code CBR, the following URL is used in the Canberra row in the dynamic table:

    locationDetail.php?recordID=CBR
  7. Save the page.

Open the detail page and pass a record ID (ASP, JSP)

  1. Select the dynamic content to double as a link.
  2. In the Server Behaviors panel (Window > Server Behaviors), click the Plus (+) button, and select Go to Detail Page from the pop‑up menu.
  3. In the Detail Page box, click Browse and locate the page.
  4. Specify the value you want to pass to the detail page by selecting a recordset and a column from the Recordset and Column pop‑up menus. Typically the value is unique to the record, such as the record’s unique key ID.
  5. If desired, pass existing page parameters to the detail page by selecting the URL Parameters or Form Parameters options.
  6. Click OK.

    A special link surrounds the selected text. When the user clicks the link, the Go To Detail Page server behavior passes a URL parameter containing the record ID to the detail page. For example, if the URL parameter is called id and the detail page is called customerdetail.asp, the URL looks something like the following when the user clicks on the link:

    http://www.mysite.com/customerdetail.asp?id=43

    The first part of the URL, http://www.mysite.com/customerdetail.asp, opens the detail page. The second part, ?id=43, is the URL parameter. It tells the detail page what record to find and display. The term id is the name of the URL parameter and 43 is its value. In this example, the URL parameter contains the record’s ID number, 43.

Open a detail page and pass a record ID (ASP.NET)

  1. Double-click your DataGrid in the Server Behaviors panel (Window > Server Behaviors).
  2. In the Columns box, select the title of the column to apply links to.
  3. Click the Change Column Type button and select Hyperlink from the pop‑up menu. The Hyperlink Column dialog box appears.
  4. In the Hyperlink Text area, specify the text to be displayed in the hyperlink column.
    Static Text
    Enter the text for the link to create a generic link, such as Details, for each row in the DataGrid. Each row in the DataGrid displays the same text (such as Details) in the hyperlink column.

    Data Field
    Select a data field in your DataSet to add links to data displayed in the column. The data field provides the text for the links in your hyperlink column. In the following example, each row in the DataGrid displays a location name:
    Each row in the DataGrid displays a location name.

  5. In the Linked Page area, build the URL to apply to the text in the hyperlink column.

    The URL not only has to open the detail page, it must uniquely identify the record to display on that page.

    To identify the record to display on the detail page, select the Data Field option and select a field in your DataSet that uniquely identifies each record. In most cases, the field consists of a record ID number. In the following example, the field consists of unique location codes:

    The field consists of unique location codes.

  6. In the Format String box in the Linked Page area, click the Browse button, and then locate and select your detail page.

    Dreamweaver creates a URL to the detail page that includes a URL parameter identifying the record the detail page should display. Make a note of the name of the URL parameter because you’ll use it in the detail page later.

    For example, if you select locationDetail.aspx as your detail page, the following URL is created:

    Example showing locationDetail.aspx as the URL in the Format String box.

    In this case, the URL parameter is called CODE. Dreamweaver copies the name of the data field, but you don’t have to use that name. You can change it to something more descriptive, such as recordID, as the following example shows:

    Example showing recordID as the URL in the Format String box.

    The {0} element is a placeholder corresponding to the data field’s value. When the page runs, the values of the DataSet’s CODE field are inserted in the corresponding rows in the DataGrid. For example, if the Canberra, Australia, rental location has the code CBR, the following URL is used in the Canberra row in the DataGrid:

    locationDetail.aspx?recordID=CBR
  7. Click OK to close the Hyperlink dialog box; then click OK to close the DataGrid dialog box.

    The DataGrid on your page updates.