DropDownList class properties and its descriptions

Web developers can use the DropDownList control to create a single-selection drop-down list control. They can control its appearance by setting BorderColor, BorderStyle, and BorderWidth properties. Items that Web developers want to appear in the control can be determined by placing a ListItem object for each entry between the opening and closing tags of the DropDownList control.

The control also supports data binding. To bind the control to a data source a data source such as a System.Collections.ArrayList object, that that contains the items to display in the control, should be created. As a next step Control.DataBind method should be used to bind the data source to the  DropDownList control. Item selected by the end user from the control can be determined programmatically by using the SelectedIndex property.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)

PropertyDescriptionSupported in .NET version
AccessKeyThis property returns or sets the access key that allows software developer to quickly navigate to the Web server control.1.0,1.1, 2.0, 3.0, 3.5, 4.0
AdapterThis property gets the browser-specific adapter for the control.2.0, 3.0, 3.5, 4.0
AppendDataBoundItemsThis property is used to get or set a value that indicates whether list items are cleared before data binding. Its default value is false. Its value is true if list items are not cleared before data binding.2.0, 3.0, 3.5, 4.0
AppRelativeTemplateSourceDirectory 

 

Software developer can use this property to set or get the application-relative path to the page or user control that contains the current control.  If the web page is installed in http://www.somesite.com/apps/application1 the property will return “~/application1”.2.0, 3.0, 3.5, 4.0
AttributesThis property is a collection which contains a collection of all attributes declared in the opening tag of a Web server control. Software developer can control programmatically the attributes associated with a Web server control. He/she can add or remove attributes to/from the collection.1.0,1.1, 2.0, 3.0, 3.5, 4.0
AutoPostBackThis value is used to get or set a value indicating whether a postback to the server automatically occurs when the user changes the list selection. Its default value is false. Its value is true if a postback to the server automatically occurs whenever the user changes the selection of the list; otherwise, false.1.0,1.1, 2.0, 3.0, 3.5, 4.0
BackColorThe property is used to specify the background color of the Web server control. Software developer can set it using a System.Drawing..::.Color object.1.0,1.1, 2.0, 3.0, 3.5, 4.0
BindingContainerSoftware developer can’t use this property directly from his/her code, because it supports the .NET Framework infrastructure.  The property contains a reference to the Control object which contains data-binding information for the current control.1.0,1.1, 2.0, 3.0, 3.5, 4.0
BorderColorThis property overwrites WebControl.BorderColor  The property is used to specify the border color of the DropDownList  control. Software developer can set it using a System.Drawing..::.Color object.1.0,1.1, 2.0, 3.0, 3.5, 4.0
BorderStyleThis property overwrites WebControl.BorderStyle. Specifies the type of the control’s border. Software developer can choose one of the values from the BorderStyle enumeration – Dashed, Dotted, Double, Grrove, Ridge, Inset, Outset, Solid and None.1.0,1.1, 2.0, 3.0, 3.5, 4.0
BorderWidthThis property overwrites WebControl. BorderWidth. Specifies the size of the control’s border.  When software developer sets this property he/she should use combination of a numeric value followed by type of measurement: px (for pixels) or % (for percentage) and so on.1.0,1.1, 2.0, 3.0, 3.5, 4.0
CausesValidationThe property gets or sets a value indicating whether validation is performed when a control that is derived from the ListControl class is clicked. Its default value is false. Its value is true if validation is performed when the ListControl control is clicked; otherwise, false. When the value of the property is set to true, Web developers can also use the ValidationGroup property to specify the name of the validation group for which the ListControl control causes validation. The value of this property is stored in view state.2.0, 3.0, 3.5, 4.0
ChildControlsCreatedGets a true value that indicates whether the server control’s child controls have been created.1.0,1.1, 2.0, 3.0, 3.5, 4.0
ClientIDReturns the server control identifier generated by ASP.NET. The ClientID value is generated by concatenating the ID value of the control and the UniqueID value of its parent control. If the ID value of the control is not specified, an automatically generated value is used. Each part of the generated ID is separated by an underscore character (_).1.0,1.1, 2.0, 3.0, 3.5, 4.0
ClientIDSeparatorThe ClientID value is generated by concatenating the ID value of the control and the UniqueID value of its parent control. Each part of the generated ID property is separated by the ClientIDSeparator property value. The value always returns an underscore (_).1.0,1.1, 2.0, 3.0, 3.5, 4.0
ContextSoftware developer can use this property to access the HttpContext object for the current Web request. Using properties of the object software developer can access objects Application, Session, Request, Response, etc. which contain information about the current HTTP request. The object provides methods that allow him to get configuration information and to set or clear errors related to the request.1.0,1.1, 2.0, 3.0, 3.5, 4.0
ControlsThis property allows software developer to access programmatically to the instance of the ControlCollection class for any server control. Using it he/she can add/remove controls to/from the collection or iterate through the server controls in the collection.1.0,1.1, 2.0, 3.0, 3.5, 4.0
ControlStyleThis property is used to encapsulate all properties of the WebControl class that specify the appearance of the control, such as BorderColor and Font. This property is used primarily by control developers.1.0,1.1, 2.0, 3.0, 3.5, 4.0
ControlStyleCreatedThis property is used primarily by control developers. Returns a true value if a Style object has been created for the ControlStyle property; otherwise false.1.0,1.1, 2.0, 3.0, 3.5, 4.0
CssClassSoftware developer can use this property to specify the CSS class to render on the client for the Web Server control. This property will render on browsers for all controls. On browsers that do not support CSS, setting the CssClass property will have no effect.1.0,1.1, 2.0, 3.0, 3.5, 4.0
DataMemberThis property used to get or set the name of the list of data that the data-bound control binds to, in cases where the data source contains more than one distinct list of data items. Its default value is String.Empty. The value of the property is stored in view state.2.0, 3.0, 3.5, 4.0
DataSourceWeb developers can use this property to get or set the object from which the data-bound control retrieves its list of data items. Its default value is null reference (Nothing in VB.NET). When Web developer sets the DataSource property, the ValidateDataSource method is called. In addition, if the data-bound control has already been initialized, the OnDataPropertyChanged method is called to set the RequiresDataBinding property to true.  This property cannot be set by themes or style sheet themes.2.0, 3.0, 3.5, 4.0
DataSourceIDThis property overwrites BaseDataBoundControl.DataSourceID and used to get or set the ID of the control from which the data-bound control retrieves its list of data items.2.0, 3.0, 3.5, 4.0
DataTextFieldThe property can be used to get or set the field of the data source that provides the text content of the list items. Its default value is String.Empty. The value of this property is stored in view state and cannot be set by themes or style sheet themes.1.0,1.1, 2.0, 3.0, 3.5, 4.0
DataTextFormatStringWeb developers can use this property to get or set the formatting string used to control how data bound to the list control is displayed. Its default value is String.Empty. The data format string consists of two parts, separated by a colon, in the form { A : Bxx }. Note: The entire string must be enclosed in braces to indicate that it is a format string and not a literal string. Any text outside the braces is displayed as literal text. 

The value before the colon (A in the general example) specifies the parameter index in a zero-based list of parameters.

Note: This value can only be set to 0 because there is only one value in each cell.

The character after the colon (B in the general example) specifies the format to display the value in and its possible values are:

–          C -displays numeric values in currency format

–          D -displays numeric values in decimal format

–          E -displays numeric values in scientific (exponential) format.

–          F -displays numeric values in fixed format.

–          G -displays numeric values in general format.

–          N -displays numeric values in number format.

–          X -displays numeric values in hexadecimal format.

Note: The format character is not case-sensitive, except for X, which displays the hexadecimal characters in the case specified.

The value after the format character (xx in the general example) specifies the number of significant digits or decimal places to display.

1.0,1.1, 2.0, 3.0, 3.5, 4.0
DataValueFieldWeb developers can use this property to get or set the field of the data source that provides the value of each list item. Its default value is String.Empty. The value of this property is stored in view state and cannot be set by themes or style sheet themes.1.0,1.1, 2.0, 3.0, 3.5, 4.0
DesignModeThis property returns true to indicate that the control is being used in the context of a designer. Software developer’s custom controls can use this property when design-time behavior is different than run-time behavior.2.0, 3.0, 3.5, 4.0
EnabledSoftware developer should set this property to true when he/she wants to specify or determine whether a control is functional. When developer sets to false, the control appears dimmed, preventing any input from being entered in the control. Notes: 

  • Not all browsers support this property. Dimming and locking the control only works in browsers that are compatible with Microsoft Internet Explorer version 4 and later.
  • In a custom composite control, this behavior does not apply to controls that have not yet created their child controls.
  • A disabled control can support postbacks. It is possible for a user who is viewing the page with a disabled control to craft a request that submits a postback that is processed by the page.
1.0,1.1, 2.0, 3.0, 3.5, 4.0
EnableThemingThis property overrides Control. EnableTheming. 

The property indicates whether themes are enabled for a specified control. When the property’s value is true, the application’s theme directory is searched for control skins to apply. If for the particular control skin does not exist in the directory, skins are not applied. When the property’s value is false, the theme directory is not searched and the contents of the SkinID property are not used.

2.0, 3.0, 3.5, 4.0
EnableViewStateSoftware developer must enable view state for the server control setting its value to true if he/she wants to maintain its state across HTTP requests. Sometimes is better to set value of this property to false if for example Web application is loading a database request into a server control. In this case application performance will be improved.1.0,1.1, 2.0, 3.0, 3.5, 4.0
EventsThis read-only property returns a list of event handler delegates for the control. The type of this property is EventHadlerList, which uses a linear search algorithm to find entries in the list of delegates. When the list of delegates is large, finding entries with this property will be slow, because a linear search algorithm is inefficient when working with a large number of entries.1.0,1.1, 2.0, 3.0, 3.5, 4.0
FontSoftware developer can use this property to specify the font properties of the Web Server control. This property includes subproperties that can be accessed declaratively in the form of Property-Subproperty (for example Font-Bold) or programmatically in the form of Property.Subproperty (for example Font.Bold). 

All but one subproperty will render in browsers prior to Microsoft Internet Explorer version 4 for all controls. They are: Bold, Italic, Name, Names, Strikeout, Underline, and Size (but only named font sizes, such as Small, Smaller, and so on, will work).

 

1.0,1.1, 2.0, 3.0, 3.5, 4.0
ForeColorSoftware developer can use this property to to specify the foreground color of the Web server control. The foreground color is usually the color of the text. This property will render on browsers earlier than Microsoft Internet Explorer version 4 for all controls, except the Image, AdRotator, HyperLink and LinkButton.1.0,1.1, 2.0, 3.0, 3.5, 4.0
HasAttributesThis property returns true when the WebControl instance has attribute name/value pairs. The attribute pairs can be set either in the property or in the view state.2.0, 3.0, 3.5, 4.0
HasChildViewStateSoftware developer can use this property to verify that any child controls of the server control are storing view-state information. Using it in this way he/she can avoid unnecessary calls to the ClearChildViewState method.1.0,1.1, 2.0, 3.0, 3.5, 4.0
HeightThis property is used to specify the height of the Web server control. When software developer sets this property he/she should use combination of a numeric value followed by type of measurement: px (for pixels) or % (for percentage) and so on.This property does not render for all controls in browsers earlier than Microsoft Internet Explorer version 4. Controls that do not render this property in earlier browsers include Label, HyperLink, LinkButton, and any validation controls. The CheckBoxList, RadioButtonList and DataList also do not render this property in earlier browsers when their RepeatLayout property is set to RepeatLayout.Flow. Furthermore, only unit types of Pixel and Percentage are supported in earlier browsers.1.0,1.1, 2.0, 3.0, 3.5, 4.0
IDWeb developers can set this property by declaring ID attribute in the opening tag of an ASP.NET server control. Another possible way to set it is programmatically. If this property is not specified for a server control, either declaratively or programmatically, Web developer can obtain a reference to the control through its parent control’s Controls property.1.0,1.1, 2.0, 3.0, 3.5, 4.0
IdSeparatorSoftware developer can’t use this property directly from his/her code, because it supports the .NET Framework infrastructure.   The character contained in this property ( by default $ ) is used to separate the control identifiers for child controls. The ID separator character is appended to the ID property.2.0, 3.0, 3.5, 4.0
InitializedReturns a value indicating whether the data-bound control has been initialized. Its value is true if true if the data-bound control has been initialized; otherwise, false. 

The ConfirmInitState and OnPagePreLoad methods both explicitly set the Initialized property to true. The ConfirmInitState method is called by the DataBoundControl.OnLoad method, while OnPagePreLoad is called when the PreLoad event is raised.

2.0, 3.0, 3.5, 4.0
IsBoundUsingDataSourceIDReturns a value indicating whether the DataSourceID property is set. The value true is returned if the DataSourceID property is set to value other than String.Empty; otherwise, the value is false. 

Controls such as GridView, DetailsView, FormView, and Menu use the IsBoundUsingDataSourceID property to determine whether the data-bound control is bound to an ASP.NET 2.0 data source control, such as an ObjectDataSource or SqlDataSource.

2.0, 3.0, 3.5, 4.0
IsChildControlStateClearedThis property has value true if children of this control do not use control state; otherwise, false.2.0, 3.0, 3.5, 4.0
IsEnabledThis property returns true if the Enabled property is true for this control and any containing controls.2.0, 3.0, 3.5, 4.0
IsTrackingViewStateThis property returns value true if the control is marked to save changes to its view state; otherwise, false. 

 

1.0,1.1, 2.0, 3.0, 3.5, 4.0
IsViewStateEnabledThis property returns value true if view state is enabled for the control; otherwise false.  View state can be enabled at the page, container, or control level. When view state is disabled at the page or container level, view state is disabled for all controls contained by the page or container. The property indicates whether view state is enabled by pages, containers, or controls. In some cases it is possible values for the EnableViewState property and the IsViewStateEnabled property to be different. For example, if the Page containing the control has view state disabled, the EnableViewState property can be true while the IsViewStateEnabled property is false. Notes: Developers will set the EnableViewState property to indicate whether they are using view state with your control. Web developers can use this property in their code to determine whether view state is enabled for their control and all containers.2.0, 3.0, 3.5, 4.0
ItemsReturns the collection of items, represented by ListItemCollection, in the list control. Its default value is an empty list.1.0,1.1, 2.0, 3.0, 3.5, 4.0
LoadViewStateByIDThis property returns value true if the control loads its view state by ID; otherwise, false. Its default value is false.2.0, 3.0, 3.5, 4.0
NamingContainerUsing this property software developer can get a reference to the server control’s naming container, which creates a unique namespace for differentiating between server controls with the same Control.ID property value.1.0,1.1, 2.0, 3.0, 3.5, 4.0
PageProvides a reference to the web page that contains this control as a System.Web.UI.Page object.  This property’s value reflects the name of the .aspx file that contains the server control.1.0,1.1, 2.0, 3.0, 3.5, 4.0
ParentThis property provides a reference to the control that contains this control. If the control is placed on the page directly (rather than inside another control), it will return a reference to the page object.1.0,1.1, 2.0, 3.0, 3.5, 4.0
RequiresDataBindingThis property is used to get or set a value indicating whether the DataBind method should be called. Its returned value is true if the data-bound control’s DataBind method should be called before the control is rendered; otherwise, the value is false. 

If Web developer sets the RequiresDataBinding property to true when the data-bound control has already begun to render its output to the page, the current HTTP request is not a callback, and Web developer is using the DataSourceID property to identify the data source control to bind to, the DataBind method is called immediately. In this case, the RequiresDataBinding property is not actually set to true.

2.0, 3.0, 3.5, 4.0
SelectArgumentsA DataSourceSelectArguments returns a value used by the data-bound control to retrieve data. Its default value is Empty. The property calls the CreateDataSourceSelectArguments method to create a default DataSourceSelectArguments object.2.0, 3.0, 3.5, 4.0
SelectedIndexThis property is used to get or set the index of the selected item in the DropDownList control. Its default value is 0, which selects the first item in the list.1.0,1.1, 2.0, 3.0, 3.5, 4.0
SelectedItemReturns the selected item with the lowest index in the list control. Its default value is null reference (Nothing in VB.NET).  If the list control allows only a single selection, Web developer should use this property to get the individual properties of the selected item. If the list control allows multiple selections, Web developer should use this property to get the properties of the lowest indexed item selected from the list control.1.0,1.1, 2.0, 3.0, 3.5, 4.0
SelectedValueReturns the value of the selected item in the list control, or selects the item in the list control that contains the specified value. Its default value is an empty string (“”).The property is used to specify the value of the selected item in the list control. If multiple items are selected, the value of the selected item with the lowest index is returned. If no item is selected, an empty string (“”) is returned. The property can also be used to select an item in the list control by setting it with the value of the item. If no items in the list control contain the specified value, a System.ArgumentOutOfRangeException is thrown. This property cannot be set by themes or style sheet themes.1.1, 2.0, 3.0, 3.5, 4.0
SiteUsing this property software developer can get information about the container that hosts the current control when rendered on a design surface.  A site binds a Component object to a Container object and enables communication between the two. It also provides a way for the container to manage its components.1.0,1.1, 2.0, 3.0, 3.5, 4.0
SkinIDThis property overrides Control.SkinID. 

Web developer can get or set the skin to apply to the control.  Skins available to a control are contained in one or more skin files in a theme directory. The SkinID property specifies which of these skins to apply to the control. A skin is specific to a particular control i.e. software developer cannot share skin setting between controls of different types. If developer does not set the SkinID property, a control uses the default skin if one is defined.

2.0, 3.0, 3.5, 4.0
StyleWeb developer can use this property to get a collection of text attributes that will be rendered as a style attribute on the outer tag of the Web server control. This property will render on all browsers for all controls.1.0,1.1, 2.0, 3.0, 3.5, 4.0
TabIndexWith this number software developer can control the tab order. The control with a TabIndex of  zero has the focus when the page first loads. If end user presses Tab his/her focus will be moved to the control with the next lowest TabIndex. This property is available only in Internet Explorer 4.0 and higher.1.0,1.1, 2.0, 3.0, 3.5, 4.0
TagKeyWeb developers can use this property to get the HtmlTextWriterTag value for the ListControl control. The TagKey property allows the output stream to write the appropriate HTML markup for the control that is derived from the ListControl class.2.0, 3.0, 3.5, 4.0
TagNameWeb developers can use this property to get the name of the control tag. This property is used primarily by control developers.1.0,1.1, 2.0, 3.0, 3.5, 4.0
TemplateControlThis property is used to get or set a reference to the template that contains this control.2.0, 3.0, 3.5, 4.0
TemplateSourceDirectorySoftware developer can use this property to get the path to the page or user control that contains the current control.  If the web page is installed in http://www.somesite.com/apps/application1 the property will return “apps/application1”.1.0,1.1, 2.0, 3.0, 3.5, 4.0
TextThe property is used to get or set the SelectedValue property of the ListControl control. The SelectedValue property is commonly used to determine the value of the selected item in the ListControl control. If no item is selected, an empty string (“”) is returned. Web developers can also use the SelectedValue property to select an item in the ListControl control by setting it with the value of the item. If no items in the ListControl control contain the specified value, an System.ArgumentOutOfRangeException exception is thrown. Control developers can override the SelectedValue property to support features that are not related to the SelectedValue property. This property cannot be set by themes or style sheet themes2.0, 3.0, 3.5, 4.0
ToolTipThis property displays a text message when the end users hover the mouse above the control.1.0,1.1, 2.0, 3.0, 3.5, 4.0
UniqueIDThis property can be used to get the unique, hierarchically qualified identifier for the server control. This property differs from the ID property, in that the UniqueID property includes the identifier for the server control’s naming container. This identifier is generated automatically when a page request is processed. This property is particularly important in differentiating server controls contained within a data-binding server control that repeats as Repeater, DataList, DetailsView, FormView, and GridView Web server controls.1.0,1.1, 2.0, 3.0, 3.5, 4.0
ValidationGroupThis property is used to get or set the group of controls for which the control that is derived from the ListControl class causes validation when it posts back to the server. Its default value is an empty string (“”). 

Validation groups allow Web developers to assign validation controls on a page to a specific category. Each validation group can be validated independently from other validation groups on the page. They should use the property to determine the name of the validation group for which the control that is derived from the ListControl class causes validation when it posts back to the server.The ValidationGroup property has an effect only when the value of the CausesValidation property is set to true. When Web developers specify a value for the ValidationGroup property, only the validation controls that are part of the specified group are validated when the ListControl control posts back to the server. If they do not specify a value for the property and the CausesValidation property is set to true, all validation controls on the page that are not assigned to a validation group are validated when the control posts back to the server.

 

The value of this property is stored in view state and cannot be set by themes or style sheet themes.

2.0, 3.0, 3.5, 4.0
ViewStateWeb developers can use this property to get a dictionary of state information that allows them to save and restore the view state of a server control across multiple requests for the same page.1.0,1.1, 2.0, 3.0, 3.5, 4.0
ViewStateIgnoresCaseThis property returns true if StateBag object is insensitive; otherwise, false. Its default value is false.1.0,1.1, 2.0, 3.0, 3.5, 4.0
VisibleWeb developers can use this property to get or set a value that indicates whether a server control is rendered as UI on the page. If the control is visible on the page this property will has value true; otherwise false.1.0,1.1, 2.0, 3.0, 3.5, 4.0
WidthThis property is used to specify the width of the Web server control. When software developer sets this property he/she should use combination of a numeric value followed by type of measurement: px (for pixels) or % (for percentage) and so on.This property does not render for all controls in browsers earlier than Microsoft Internet Explorer version 4. Controls that do not render this property in earlier browsers include Label, HyperLink, LinkButton, and any validation controls. The CheckBoxList, RadioButtonList and DataList also do not render this property in earlier browsers when their RepeatLayout property is set to RepeatLayout.Flow. Furthermore, only unit types of Pixel and Percentage are supported in earlier browsers.1.0,1.1, 2.0, 3.0, 3.5, 4.0