Skip to content

<DualList>

The DualList tag renders two side-by-side listboxes separated by a row of movement buttons (>, <, >>, <<). The user moves items between the two boxes; the contents of the right-hand box are what get saved to the database. It's a more interactive alternative to a multi-select listbox or a checkbox list when the source list is long.

JavaScript required

The DualList moves items between the two listboxes via JavaScript. The control will not function correctly with JavaScript disabled in the browser.

Example

html
<AddForm>
  ...
  <table>
    <tr>
       <td>
        <Label For="txtFirstName" Text="First Name" />
        <TextBox Id="txtFirstName" DataField="FirstName" DataType="string" />
      </td>
    </tr>
    <tr>
      <td>
        <Label For="lstColors" Text="Favorite Colors" />
        <DualList Id="lstColors" DataField="FavoriteColors" DataType="string">
          <ListItem Value="#00FF00">Green</ListItem>
          <ListItem Value="#FF0000" Selected="true">Red</ListItem>
          <ListItem Value="#0000FF">Blue</ListItem>
        </DualList>
      </td>
    </tr>
    <tr>
      <td colspan="2">
        <AddButton Text="Add"/> <CancelButton Text="Cancel"/>
      </td>
    </tr>
  </table>
</AddForm>

Properties

PropertyValuesDefaultDescription
ID *stringUnique identifier for the control within the form
DataFieldstringParameter name for data binding to your form's data commands
DataTypeStringStringDatabase type — must be String because the selected values are joined into a delimited string
AppendDataBoundItemsTrue FalseFalseWhen True, items retrieved from a <ControlDataSource> are appended to inline <ListItem> children rather than replacing them
ButtonStylestyle attributesStyling for the four movement buttons — uses ASP.NET nested style syntax (e.g. ButtonStyle-CssClass="my-btn")
CssClassstringCSS class name(s) for styling the wrapping <table> element
DataSourceIDstringID of a <ControlDataSource> tag whose data fills the source listbox
DataTextFieldstringWhen data-bound, the source column whose value is shown as each item's display text
DataTextFormatStringformat stringA .NET format string applied to each item's display text
DataValueFieldstringWhen data-bound, the source column whose value becomes each item's hidden value
EnabledTrue FalseTrueWhen False, the control is disabled (grayed out and not interactive)
HeightsizeHeight of the wrapping element
ListStylestyle attributesStyling applied to both listboxes — uses ASP.NET nested style syntax (e.g. ListStyle-Width="200", ListStyle-CssClass="my-list")
NullableTrue FalseFalseReturns DBNull when the right-hand listbox is empty
SelectedItemsSeparatorstring|Character(s) used to join values together when more than one item is selected
StylestringInline CSS for the wrapping element
TabIndexintegerTab order for keyboard navigation
ToolTipstringText displayed on mouse hover
VisibleTrue FalseTrueShows or hides the control
WidthsizeWidth of the wrapping element

* Required property

Deprecated Properties

These properties use ASP.NET inline styling and are no longer recommended for modern web development. Use the CssClass property to apply CSS classes or the Style property for inline CSS instead.

PropertyValuesDescription
BackColorcolor name | #ddddddBackground color of the control
BorderColorcolor name | #ddddddBorder color of the control
BorderStyleNotSet None Dotted Dashed Solid Double Groove Ridge Inset OutsetBorder style of the control
BorderWidthsizeBorder width of the control
Font-BoldTrue FalseBold text
Font-ItalicTrue FalseItalic text
Font-NamesstringFont family name
Font-OverlineTrue FalseOverline text decoration
Font-SizeXX-Small X-Small Small Medium Large X-Large XX-Large or sizeFont size
Font-StrikeoutTrue FalseStrikethrough text decoration
Font-UnderlineTrue FalseUnderline text decoration
ForeColorcolor name | #ddddddText color of the control

The ListStyle and ButtonStyle properties accept the same set of nested style attributes (e.g. ListStyle-Font-Bold, ButtonStyle-ForeColor). These are likewise deprecated — prefer styling the listboxes and buttons via ListStyle-CssClass and ButtonStyle-CssClass (or via CSS rules targeting the rendered elements).

Property Details

  • ID: Name, consisting of letters and numbers, beginning with a letter, that uniquely identifies the control within the form.

  • DataField: Name of the parameter in the <SubmitCommand> which will be filled with the selected values when the form is submitted and/or the parameter in the <SelectCommand> which will supply this control's data when the form is loaded. This attribute is required if the control will participate in operations with your form's data commands.

  • DataType: Always String for this control. Because multiple items can be selected, the selected values are joined into a single delimited string (see SelectedItemsSeparator) — even if the underlying values are numeric, the value sent to the database is always a string like "32|578|38".

  • AppendDataBoundItems: When True and the control is bound to a <ControlDataSource>, the items returned by the data source are appended to any inline <ListItem> children. When False (the default), the bound data replaces inline items.

  • DataSourceID: ID of a <ControlDataSource> tag whose data fills the source (left-hand) listbox. Required only if the source items come from a data source. (The casing — capital ID — comes from the underlying ASP.NET ListControl; XMP markup is case-insensitive.)

  • DataTextField: When using a <ControlDataSource>, the column name whose value supplies each list item's display text. Required when DataSourceID is set.

  • DataValueField: When using a <ControlDataSource>, the column name whose value supplies each list item's hidden value. Required when DataSourceID is set.

  • ButtonStyle: Styling for the four movement buttons (>, <, >>, <<). Uses ASP.NET nested style syntax: prefix any style attribute with ButtonStyle- (e.g. ButtonStyle-CssClass="my-button", ButtonStyle-Width="40"). For modern styling, prefer ButtonStyle-CssClass and define the rules in your stylesheet.

  • ListStyle: Styling applied to both the source and selected listboxes. Uses ASP.NET nested style syntax: prefix any style attribute with ListStyle- (e.g. ListStyle-Width="200", ListStyle-CssClass="my-list"). For modern styling, prefer ListStyle-CssClass.

  • Nullable: When True and the right-hand (selected items) listbox is empty, the control returns DBNull to the data commands. If a DBNull value is passed back to the control (e.g. when loading a record for editing), all items are returned to the source listbox regardless of the Nullable setting.

  • SelectedItemsSeparator: When more than one item is in the right-hand listbox, the control merges those values into a single string using a separator. The default separator is the pipe character (|). For example, if items 32, 578, and 38 are selected, the value sent to the database would be "32|578|38". If only one item is selected, no separator is used.

    Email lists

    If you are using this control to supply email addresses to the <Email> tag, the Email tag expects a pipe-delimited list by default. However, since email recipient lists are usually comma-delimited elsewhere, you can set SelectedItemsSeparator="," and the Email tag will still parse them correctly.