The Listbox tag renders as a single or multi-select listbox at run-time.
<ListBox
AccessKey="string"
AppendDataBoundItems="True|False"
BackColor="color name|#dddddd"
BorderColor="color name|#dddddd"
BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge| Inset|Outset"
BorderWidth="size"
CssClass="string"
DataField="string"
DataSourceID="string"
DataTextField="string"
DataTextFormatString="string"
DataType="string|int32|...."
DataValueField="string"
Font-Bold="True|False"
Font-Italic="True|False"
Font-Names="string"
Font-Overline="True|False"
Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium| Large|X-Large|XX-Large"
Font-Strikeout="True|False"
Font-Underline="True|False"
ForeColor="color name|#dddddd"
Height="size"
ID="string"
Rows="integer"
SelectedItemsSeparator="string||"
SelectionMode="Single|Multiple"
Style="string"
TabIndex="integer"
ToolTip="string"
Visible="True|False"
Width="size">
<ListItem value="string" selected="True|False">Item1</ListItem>
<ListItem value="string">Item2</ListItem>
...
</ListBox>
<controldatasource>
tag will be appended to the list of items already defined in the control. This only applies if the control is bound to such a tag. The default value is False.<submitcommand>
which will be filled with this control's data on 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.<controldatasource>
tag, specify that tag's ID in this attribute. This attribute is required only if the control's data is supplied via a <controldatasource>
tag.<controldatasource>
this attribute specifies the column name in that datasource that supplies each list item's display text. This attribute is required if the control's data is supplied via a <controldatasource>
tag.<controldatasource>
this attribute specifies the column name in that datasource that supplies each list item's hidden value. This attribute is required only if the control's data is supplied via a <controldatasource>
tag.|
) as a separator. You can change the character used to separate the selected values using this property. If, for instance, you wanted to separate them with a comma, you would set SelectedItemsSeparator=","
The separator is only used on controls capable of multiple selection and ONLY when more than one item has been selected. <email>
tag, it assumes values are delimited with a pipe. However, since email addresses are comma-delimited, you could set SelectedItemsSeparator to a comma and it should still function.<listitem>
child tags which define the items that will appear in the list. The control can also be bound to a <controldatasource>
tag. To do so, specify the ID of the <controldatasource>
tag in the Listbox's "datasourceid" attribute, the name of the column in the data source that should supply the display text for each list item, and the column in the data source that should supply the hidden value of each list item.
<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 Color" />
<listbox id="lstColors" datafield="FavoriteColors"
datatype="string" selectionmode="single">
<listitem value="#00FF00">Green</listitem>
<listitem value="#FF0000" selected="true">Red</listitem>
<listitem value="#0000FF">Blue</listitem>
</listbox>
</td>
</tr>
<tr>
<td colspan="2">
<addbutton text="Add"/> <cancelbutton
text="Cancel"/>
</td>
</tr>
</table>
</addform>
<AddForm>
... <ControlDataSource Id="dsColors" CommandText="SELECT ColorId, ColorName FROM MyColorsTable"/> ... <ListBox Id="lstColors" DataSourceId="dsColors" DataTextField="ColorName" DataValueField="ColorId" DataField="FavoriteColor" DataType="Int32" />
</AddForm>
This example shows how to use the AppendDataBoundItems property to add a "None Selected" item to a list that is being populated from a table.
<AddForm>
... <ControlDataSource Id="dsColors" CommandText="SELECT ColorId, ColorName FROM MyColorsTable"/> ... <ListBox Id="lstColors" DataSourceId="dsColors" DataTextField="ColorName" DataValueField="ColorId" DataField="FavoriteColor" DataType="Int32" AppendDataBoundItems="True"> <ListItem Value="-1">(None Selected)</ListItem> </ListBox>
</AddForm>