Home   |   QuickStart Welcome   |   ASP.NET   |   Web Services   |   How Do I...?   
  |   I want my samples in...      

ASP.NET 2.0 Quickstart Tutorials

DropDownList

The DropDownList control provides a single-select drop-down list. The following sample illustrates using a simple DropDownList control.

VB DropDownList1.aspx
Run Sample View Source

The following sample illustrates using data binding to a static ArrayList with a DropDownList control.

VB DropDownList2.aspx
Run Sample View Source

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.

VB DropDownList3.aspx
Run Sample View Source

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.