DropDownList Class
Represents a control that allows the user to select a single item from a drop-down list.
Assembly: System.Web (in System.Web.dll)
[ValidationPropertyAttribute(L"SelectedItem")] [AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)] [AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)] public ref class DropDownList : public ListControl, IPostBackDataHandler
<asp:DropDownList />
Use the DropDownList control to create a single-selection drop-down list control. You can control the appearance of the DropDownList control by setting the BorderColor, BorderStyle, and BorderWidth properties.
To specify the items that you want to appear in the DropDownList control, place a ListItem object for each entry between the opening and closing tags of the DropDownList control.
The DropDownList control also supports data binding. To bind the control to a data source, create a data source, such as a System.Collections::ArrayList object, that contains the items to display in the control. Then, use the Control::DataBind method to bind the data source to the DropDownList control.
Use the SelectedIndex property to programmatically determine the index of the item selected by the user from the DropDownList control.
Accessibility
The markup rendered by default for this control might not conform to accessibility standards such as the Web Content Accessibility Guidelines 1.0 (WCAG) priority 1 guidelines. For details about accessibility support for this control, see ASP.NET Controls and Accessibility.
A Visual Studio Web site project with source code is available to accompany this topic: Download.
The following code example demonstrates how to create a DropDownList control that contains four items.
The following code example demonstrates how to create a DropDownList control though data binding.
- AspNetHostingPermission
For operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission
For operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.