Repeat Selection

The Repeat Selection server behavior allows you to select a portion of code in your page and repeat it a specific number of times. When used with a recordset on the page, records returned can be iterated through and displayed on the page in the repeated area.

Dreamweaver's Repeat Region server behavior allows you to repeat recordset content across a repeating region, but only in a single direction. It can be applied to a table row, thus repeating recordset content vertically, or it can be applied to a table cell, repeating content horizontally.

The DataAssist Repeat Selection server behavior, when used in conjunction with the the Dreamweaver Repeat Region server behavior, allows you to control the number of records displayed in each row, for multiple rows.

As this is a common application of these two server behaviors, DataAssist includes the Repeating Table feature specific to easily configuring their use together. The DataAssist Wizard also creates this common application of the two server behaviors when configuring a results page display discussed in the Recordset paging section of the wizard.

As well, Repeat Selection can be used in conjunction with Dreamweaver's Recordset Navigation Bar to move through a selection of records returned by the recordset that exceeds the number configured for display.

When the server behavior is applied, it adds a Counter binding available on the page through the Bindings panel. This binding is used directly within the server behavior as a loop counter, incrementing for each iterations of the selected region it has displayed until it reaches its configured number. It is also used primarily with the Insert Multiple Records and Update Multiple Records server behaviors to increment the names of repeated form fields. It can also be helpful for display as a row counter.

Access

The Repeat Selection server behavior can be accessed in the following location:
  • Server Behaviors panel > Plus icon (+) > WebAssist > DataAssist > Repeat Selection

Application

To apply the server behavior correctly, select the region on the page to be repeated. For example, if repeating a row in a table, be sure that the <tr> to be repeated is highlighted on the page at the time the server behavior is applied. Multiple types of tags that encompass an area on the page can be used, ranging, from table cells (<td>), table rows (<tr>), and full tables (<tables>) to paragraphs (<p>) list items (<li>) and DIVs (<div>).

Note: Be sure that when you apply the server behavior to a table cell, you take the existing structure of the table into account. Ensure that the number of table cells displayed within the repeated selection area coincides with the number of cells displayed in other rows in the same table that are not included encompassed by the server behavior. This will prevent any display abnormalities caused by different rows in the table having a different number of table cells.


Repeat options

Configure the attributes for the content and the number of times it is to be repeated. If you are looping through a recordset and repeating a region to display content from distinct records, select the recordset on the page that returns the data to be displayed. Select the number of times the region is to be repeated. If additional iterations are specified, but there are not enough records to complete the display, enter the alternate content to be used as placeholder content.



Recordset: A list of available recordsets on the current page. Select None if you are not using the server behavior to display recordset content. Otherwise, select the recordset specific to the data to be displayed in the selection.

Repetitions: The number of times the selected content is to be repeated. Select from the list of available options, or enter a custom numeric value. A dynamic value can also be specified using the dynamic data source dialog accessed through the lightning bolt icon.

Alternative content: Additional content that is to be output when a recordset has been exhausted.  This content should contain the appropriate structure to ensure that design elements are rendered appropriately. To assist in this, the following default content options are displayed depending on the selection the server behavior is applied to, and whether a recordset is selected:
  • <td> selected on the page: "<td>&nbsp;</td>"
  • Recordset selected in the "Recordset" field, and <tr> selected on the page: "<tr><td>&nbsp;</td></tr>"
  • If more than one table cell is found within the selected <tr>, then the alternative content <tr> contains the same number of table cells containing non-breaking spaces.

Repeat Selection data binding

The Repeat Selection selection server behavior uses a Counter binding specific to each application of the server behavior on a given page. Dragging the binding to the page adds code that outputs the current value of the loop counter for the selected Repeat Selection data binding. This counter binding is primarily used by the Insert Multiple Records and Update Multiple Records server behaviors to increment form field names. This binding can also be used as a row counter.

Note: The counter value starts at 0, so you may wish to add 1 to the current value in the binding code if using it for display considerations (e.g. <%=RepeatSelectionCounter_1+1%>).