Web developers use the HtmlSelect control to create a selection box. They can determine item listings in the control by placing HTML <option> elements between the opening and closing <select> tags. Each item is represented by a System.Web.UI.WebControls.ListItem object.  Developers can specify the text that is displayed for each item in the control, by setting the ListItem.Text property of the item, or they can simply place text between the opening and closing <option> tags. By setting the ListItem.Value property of the item, Web developers can associate a value with the item that is different from the text. To select an item from the list by default, they should set the ListItem.Selected property of the item to true.

Appearance and behavior of the HtmlSelec can be controlled by setting the Size and Multiple properties where:

–          The Size property specifies the height (in rows) of the control
–          The Multiple property specifies whether more than one item can be concurrently selected in the HtmlSelect control.

By default, the HtmlSelect control is displayed as a drop-down list box. The control is displayed as a list box if Multiple property is set to true or height is specified greater than one row (by setting the Size property to a value greater than 1).

The HtmlSelect class provides two properties to support data binding:

–          To bind data to any object that implements the System.Collections.Enumerable interface (such as System.Data.DataView, System.Collections.ArrayList, and System.Collections.Hashtable), or the IListSource interface, Web developers should use the DataSource property to specify the data source to bind to, but they must manually write the code to perform the data binding.
–          To automatically bind an HtmlSelect control to a data source represented by a data source control, Web developers should use the DataSourceID property and set its value to the ID property of the data source control to use. When they set the DataSourceID property, the HtmlSelect control automatically binds to the specified data source control and they do not need to explicitly call the DataBind method.

Web developers can determine which fields in the data source bind to the ListItem.Text and ListItem.Value properties of an item in the control by setting the DataTextField and DataValueField properties, respectively. If the data source contains multiple sources of data, they have to use the DataMember property to specify the specific source to bind to the control.

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

Property Description Supported in .NET version
Adapter This property gets the browser-specific adapter for the control. If the target browser does not require an adapter, returns a null reference (Nothing in VB.NET). The property returns the ControlAdapter object that renders the control on the requesting device or browser’s screen. 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 https://www.somesite.com/apps/application1 the property will return “~/application1”. 2.0, 3.0, 3.5, 4.0
Attributes Web developer can use this property to get a collection of all attribute name and value pairs expressed on a server control tag within the ASP.NET page. Using this property Web developer accesses the attributes of the HTML server control which are stored in Control.ViewState property. HTML attributes are treated by the .NET Framework as properties on the HTML server control to which they belong. 1.0,1.1, 2.0, 3.0, 3.5, 4.0
BindingContainer Software 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
ChildControlsCreated Gets 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
ClientID Returns 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
ClientIDSeparator The 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
Context Software 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
Controls This 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
DataMember The property is used to get or set the set of data to bind to the HtmlSelect control from a DataSource property with multiple sets of data. Its efault value is an empty string (“”), which indicates the property has not been set. After Web developers have determined the data source to bind to the control, they can then specify which fields from the data source to bind to the ListItem.Text and ListItem.Value properties of each item in the control by setting the DataTextField and DataValueField properties, respectively. 1.0,1.1, 2.0, 3.0, 3.5, 4.0
DataSource This property is used to get or set the source of information to bind to the HtmlSelect control. A data source must be an object that implements either the System.Collections.IEnumerable interface (such as System.Data.DataView,System.Collections.ArrayList, or System.Collections.Hashtable) or the IListSource interface. When web developer sets the DataSource property, he/she must manually write the code to perform data binding. If the data source contains multiple sets of data, such as a System.Data.DataSet object with multiple tables, Web developer should use the DataMember property to specify which data set to bind to the control. Web developer can specify which fields from the data source to bind to the ListItem.Text and ListItem.Value properties of each item in the control by setting the DataTextField and DataValueField properties, respectively. Alternately, Web developer can use the DataSourceID property to automatically bind to a data source represented by a data source control. When he/she sets the DataSourceID property, the data listing control automatically binds to the specified data source control and he/she does not need to write code that explicitly calls the DataBind method.Note: If values are specified for both the DataSource property and the DataSourceID property, ASP.NET is not able to resolve the data source and a System.Web.HttpException exception is thrown. 1.0,1.1, 2.0, 3.0, 3.5, 4.0
DataSourceID This property is used to get or set the ID property of the data source control that the HtmlSelect control should use to retrieve its data source. The data source control referenced by the DataSourceID property can be any control that implements the IDataSource interface. The data source control must exist either in the same naming container as the HtmlSelect control that references it or in a parent control of the HtmlSelect control. When Web developer specifies a value for this property, the HtmlSelect control automatically binds to the specified data source control and he/she does not need to write code that explicitly calls the DataBind method. 2.0, 3.0, 3.5, 4.0
DataTextField The property is used to get or set the field from the data source to bind to the ListItem.Text property of each item in the HtmlSelect control. Its default value is an empty string (“”), which indicates that the property has not been set.  This property is commonly used to provide a value for the ListItem.Text property that differs from the value of the ListItem.Value property. 1.0,1.1, 2.0, 3.0, 3.5, 4.0
DataValueField The property is used to get or set the field from the data source to bind to the ListItem.Value property of each item in the HtmlSelect control. Its default value is an empty string (“”), which indicates that the property has not been set.  This property is commonly used to provide a value for the ListItem.Value property that differs from the value of the ListItem.Text  property. 1.0,1.1, 2.0, 3.0, 3.5, 4.0
DesignMode This 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
Disabled This property is used to get or set a value indicating whether the HTML server control is disabled. Its default value is false i.e. the control is enabled. In the browser, a disabled element or control is read-only, with the following added restrictions:- its value is not submitted with the form,

– the element or control cannot receive focus

– the element or control is skipped when navigating the document by tabbing.

1.0,1.1, 2.0, 3.0, 3.5, 4.0
EnableTheming This 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
EnableViewState Software 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
Events This 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
HasChildViewState Software 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
ID Web 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
IdSeparator Software 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
InnerHtml This property gets or sets (modifies) the content found between the opening and closing tags of the specified HTML server control. The property does not automatically encode special characters to and from HTML entities. HTML entities allow Page developers to display special characters, such as the < character, that a browser would ordinarily interpret as having special meaning. The < character would be interpreted as the start of a tag and is not displayed on the page. To display the < character, Page developer should use the entity &lt;.Note: Because the text is not HTML encoded, it possible to embed script within HTML tags in the text. If this property is set dynamically using user input, Web developers should be sure to validate the value to reduce security vulnerabilities. 1.0,1.1, 2.0, 3.0, 3.5, 4.0
InnerText This property gets or sets (modifies) the text between the opening and closing tags of the specified HTML server control. Unlike the InnerHtml property, the InnerText property automatically encodes special characters to and from HTML entities. HTML entities allow Page developers to display special characters, such as the < character, that a browser would ordinarily interpret as having special meaning. The < character would be interpreted as the start of a tag and is not displayed on the page. To display the < character, they should use the entity &lt;.Note: If there are no child controls, the InnerHtml property contains the value String.Empty. 1.0,1.1, 2.0, 3.0, 3.5, 4.0
IsChildControlStateCleared This property has value true if children of this control do not use control state; otherwise, false. 2.0, 3.0, 3.5, 4.0
IsTrackingViewState This 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
IsViewStateEnabled This 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
Items Returns a collection that contains the items listed in an HtmlSelect control. The Items is commonly used to iterate through the items in the HtmlSelect control and Web developers can programmatically add items to, remove items from, and insert items into the collection. 1.0,1.1, 2.0, 3.0, 3.5, 4.0
LoadViewStateByID This 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
Multiple This Boolean property is used to get or set a value indicating whether multiple items can be selected concurrently in the HtmlSelect control. Its default value is false.  By default, the HtmlSelect control is displayed as a drop-down list box. If Web developer allows multiple selections (by setting the Multiple property to true) or specifies a height greater than one row (by setting the Size property to a value greater than 1), the control is displayed as a list box.To determine the selected items in an HtmlSelect control that allows multiple simultaneous selections, Web developer should iterate through the Items collection and test the ListItem. Selected property of each item. 1.0,1.1, 2.0, 3.0, 3.5, 4.0
Name This property gets or sets the unique identifier name associated with the HtmlSelect control.  Note: The set accessor does not assign a value to this property because the Name property must have the same value as the Control.UniqueID property for the HtmlSelect control to work properly. 1.0,1.1, 2.0, 3.0, 3.5, 4.0
NamingContainer Using 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
Page Provides 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
Parent This 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
RequiresDataBinding This Boolean property is used to get or set a value indicating whether the HtmlSelect control needs to bind to its specified data source. Each time the set accessor is called on either the DataSource, DataSourceID, or DataMember property to change the data source after the OnInit method has already been called, ASP.NET automatically sets the value of the RequiresDataBinding property to true. The value of the RequiresDataBinding property is also set to true when the OnDataPropertyChanged method is invoked. ASP.NET automatically sets the value of the RequiresDataBinding property to false immediately after the DataBind method has been called. 2.0, 3.0, 3.5, 4.0
SelectedIndex This property is used to get or set the ordinal index of the selected item in an HtmlSelect control. A value of -1 indicates that no item is selected. If the Multiple property is set to true, indicating that multiple items can be concurrently selected, the SelectedIndex property contains the index of the first selected item. Web developer can determine the selected items from an HtmlSelect control that allows multiple simultaneous selections, by iterating through the Items collection and test the ListItem.Selected property of each item.Note: It is possible to have no item selected. If no item is selected, the SelectedIndex property contains a value of -1. This commonly occurs when the page first loads and an item is not selected by default. Web developer should use a code to test this value before referencing the item in the Items collection. Otherwise, an exception is thrown if the index is out of the range of the collection. 1.0,1.1, 2.0, 3.0, 3.5, 4.0
SelectedIndices Returns a collection that contains the zero-based indexes of all currently selected items in the HtmlSelect control. Control developers extending the functionality of the HtmlSelect class can override the SelectedIndices property to provide a custom algorithm for returning currently selected items. 1.0,1.1, 2.0, 3.0, 3.5, 4.0
Site Using 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
Size This property is used to get or set the height (in rows) of the HtmlSelect control. If specified size is smaller than the number of items in the control, scroll bars are displayed to allow users to move up and down the list. By default, the HtmlSelect control is displayed as a drop-down list box. If Web developer allows multiple selections (by setting the Multiple property to true) or specifies a height greater than one row (by setting the Size property to a value greater than 1), the control is displayed as a list box.  1.0,1.1, 2.0, 3.0, 3.5, 4.0
SkinID This 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
Style Web 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
TagName Web 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
TemplateControl This property is used to get or set a reference to the template that contains this control. 2.0, 3.0, 3.5, 4.0
TemplateSourceDirectory Software 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 https://www.somesite.com/apps/application1 the property will return “apps/application1”. 1.0,1.1, 2.0, 3.0, 3.5, 4.0
UniqueID This 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
Value Returns the value of the selected item in the HtmlSelect control or sets the SelectedIndex property of the control to the index of the first item in the list with the specified value.Note: If no item is selected in the control, String.Empty is returned. 1.0,1.1, 2.0, 3.0, 3.5, 4.0
ViewState Web 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
ViewStateIgnoresCase This 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
Visible Web 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