DropDownList

The DropDownList web server control enables users to select an item from a predefined list. It differs from the ListBox web server control in that the list of items remains hidden until users click the drop-down button. In addition, the DropDownList control differs from the ListBox control because it does not support multi-selection mode.

To add a DropDownList control to a page

  • Drag the DropDownList control from the Toolbox panel to your page.

    For a full description of all DropDownList control properties, see DropDownList Properties Cc295080.xtlink_newWindow(en-us,Expression.40).png in the MSDN library.

To bind the DropDownList control to a data source

  1. In Design view, right-click the DropDownList control, and then click ShowCommon Control Tasks****.

  2. On the Common DropDownList Tasks menu, click Choose Data Source.

  3. In the Data Source Configuration Wizard, choose a source for the DropDownList control in the Select a data source drop-down box. In the Select a data field to displayin the DropDownList**** drop-down box, select the field for the text that the user will see. In the Select a data field for the value of the DropDownList drop-down box, select the field for the data that can be programmatically accessed when the user chooses an item in the list.

To define items for the DropDownList control

  1. In Design view, right-click the DropDownList control, and then click ShowCommon Control Tasks****.

  2. On the Common DropDownList Tasks menu, click Edit Items.

  3. In the ListItem Collection Editor dialog box, click Add to add an item.

  4. In the ListItem properties list, set the Text and Value properties.

  5. Repeat steps 3 and 4 until you have added all the items that you want.

    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.

    Note

    You cannot specify the number of items that are displayed in the list before a scroll bar appears when users click the drop-down button. The length of the displayed list is determined by the browser.

See also

Concepts

Working with ASP.NET sites
ASP.NET Data controls
ASP.NET Validation controls
ASP.NET Navigation controls
ASP.NET Login controls
ASP.NET WebParts controls

Other resources

ASP.NET Standard controls

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.