The DropDownList control enables users to select from a single-selection drop-down list. The drop-down portion can contain any number of list items.
Required properties are noted in boldface type.
<asp:DropDownList id="DropDownList1" runat="server" DataSource="<% databindingexpression %>" DataTextField="DataSourceField" DataValueField="DataSourceField" AutoPostBack="True|False" OnSelectedIndexChanged="OnSelectedIndexChangedMethod" /> <asp:Listitem value="value" selected="True|False"> Text </asp:Listitem> </asp:DropDownList>
Property | Description |
---|---|
(Base control properties) | The properties defined in Base Web Control Properties. |
AutoPostBack | True if client-side changes in the control automatically cause a postback to the server; false otherwise. The default is false. |
DataTextField | The field or property of the object in DataSource that will be the source of data for the Text property of individual list items. |
DataValueField | The field or property of the object in DataSource that will be the source of data for the Value property of individual list items. |
DataSource | A data-binding expression that references any object that supports the ICollection interface. |
Items | A collection of ListItem objects representing individual items within the drop-down list.
This property is only used when programming. At design time, you set this property by declaring <asp:ListItem> items. |
SelectedIndex | The ordinal index of the currently-selected item in the drop-down list.
This property is only used when programming. At design time, you set this property by including a Selected property in a ListItem element. |
SelectedItem | A reference to the Value property of the currently selected item in the list.
This property is only used when programming. At design time, you set this property by including a Selected property in a ListItem element. |
Property | Description |
---|---|
Selected | true if the item is the one selected in the drop-down list and that appears in the text box; false otherwise. Only one item can be declared as selected. |
Text | The text that appears in the list. This property is primarily for display; the Value property contains the actual selection. |
Value | The value of the item selected by the user, which can be different from the text displayed in the list. This property is the one available in the SelectedItem property of the DropDownList control. |
Event (and paramters) | Description |
---|---|
OnSelectedIndexChanged(Object sender, EventArgs e) | Raised on the server when the selection of the DropDownList control changes. This event does not cause the Web Forms page to be posted to the server unless the AutoPostBack property is set to true.
The e events argument object has no properties. |
Example
To be supplied.
See Also