Standard Controls[7]->DropDownList
The DropDownList control provides a single-select drop-down list. The following sample illustrates using a simple DropDownList control.
The following sample illustrates using data binding to a static ArrayList with a DropDownList control.
In addition to programmatically databinding, as shown in the example above, you can also data bind a DropDownList declaratively to a data source control. The following example shows a DropDownList bound to the Authors table in the Pubs database.
Note that the DropDownList includes DataTextField and DataValueField properties for specifying the field value to render for the Text and Value properties of its list items, respectively. The value of the currently selected item is exposed through the SelectedValue property of DropDownList. All controls that derive from ListControl (includes DropDownList) follow this pattern.
The following sample illustrates using data binding to a static ArrayList with a DropDownList control.
In addition to programmatically databinding, as shown in the example above, you can also data bind a DropDownList declaratively to a data source control. The following example shows a DropDownList bound to the Authors table in the Pubs database.
Note that the DropDownList includes DataTextField and DataValueField properties for specifying the field value to render for the Text and Value properties of its list items, respectively. The value of the currently selected item is exposed through the SelectedValue property of DropDownList. All controls that derive from ListControl (includes DropDownList) follow this pattern.


浙公网安备 33010602011771号