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
To specify the items that you want to appear in the control, place a ListItem object for each entry between the opening and closing tags of the control.
The 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 control.
Use the SelectedIndex property to programmatically determine the index of the item selected by the user from the control.
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 control that contains four items.
The following code example demonstrates how to create a control though data binding.
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.