The
Modifying the Appearance of the DropDownList Control
You can control the look of the DropDownList control by setting its height and width in pixels. Some browsers do not support setting the height and width in pixels and will use the row-count setting instead.
You cannot specify the number of items that are displayed in the list when users click the drop-down button. The length of the displayed list is determined by the browser.
As with other Web server controls, you can use style objects to specify the appearance of the DropDownList control. For details, see
List Items
The DropDownList control is actually a container for the list items, which are of type
Property | Description |
---|---|
|
Specifies the text that is displayed in the list. |
|
Contains the value that is associated with an item. Setting this property allows you to associate a value with a specific item without displaying it. For example, you can set the Text property to the name of a U.S. state and the Value property to its postal abbreviation. |
|
Indicates whether the item is selected by means of a Boolean. |
To work with list items programmatically, use the
The currently selected item is available in the DropDownList control's
Binding Data to the Control
You can use a DropDownList Web server control to list options that are made available to the page using a data source control. Each item in the DropDownList control corresponds to an item — typically a row — in the data source.
The control displays one field from the source. Optionally, you can bind the control to a second field to set the value of an item, which does not display.
As with other Web server controls, you can bind any control properties, such as the color or size of the control, to data. For details, see How to: Populate List Web Server Controls from a Data Source.
DropDownList Events
The DropDownList control raises an event — the
Note |
---|
The ability of a DropDownList control to post to the server when it is checked requires that the browser support ECMAScript (JScript, or JavaScript) and that scripting be enabled on the user's browser. |