System.Web.UI.HtmlControls (system.web.dll)class

This class represents the HTML <select> tag, which allows the user to choose an option from a drop-down list box. To add an item to the list, use the Add( ) method of the Items property. The HtmlSelect control also supports data binding to its Items property.

To retrieve the currently selected item, you can use SelectedIndex property to find the ordinal number of the chosen item (-1 if no selection has been made), or the Value property to retrieve the text of the selected item. If you have set Multiple to True, more than one item may be selected and only the first item will be returned by the SelectedIndex and Value properties. Instead, you will have to iterate through the Items collection and check the System.Web.UI.WebControls.ListItem.Selected property for each one.

You can also react to the ServerChange event, which will fire only after a postback is triggered (for example, when the user clicks a submit button).

public class HtmlSelect : HtmlContainerControl, System.Web.UI.IPostBackDataHandler {
// Public Constructors
   public HtmlSelect( );
// Public Instance Properties
   public virtual string DataMember{set; get; }
   public virtual object DataSource{set; get; }
   public virtual string DataTextField{set; get; }
   public virtual string DataValueField{set; get; }
   public override string InnerHtml{set; get; }                  // overrides HtmlContainerControl
   public override string InnerText{set; get; }                  // overrides HtmlContainerControl
   public ListItemCollection Items{get; }
   public bool Multiple{set; get; }
   public string Name{set; get; }
   public virtual int SelectedIndex{set; get; }
   public int Size{set; get; }
   public string Value{set; get; }
// Protected Instance Properties
   protected virtual int[ ] SelectedIndices{get; }
// Protected Instance Methods
   protected override void AddParsedSubObject(object obj);      // overrides System.Web.UI.Control
   protected virtual void ClearSelection( );
   protected override ControlCollection CreateControlCollection( ); // overrides HtmlContainerControl
   protected override void LoadViewState(object savedState);    // overrides HtmlContainerControl
   protected override void OnDataBinding(EventArgs e);          // overrides System.Web.UI.Control
   protected override void OnPreRender(EventArgs e);            // overrides System.Web.UI.Control
   protected virtual void OnServerChange(EventArgs e);
   protected override void RenderAttributes(System.Web.UI.HtmlTextWriter writer); // overrides HtmlContainerControl
   protected override void RenderChildren(System.Web.UI.HtmlTextWriter writer); // overrides System.Web.UI.Control
   protected override object SaveViewState( );       // overrides System.Web.UI.Control
   protected virtual void Select(int[ ] selectedIndices);
   protected override void TrackViewState( );        // overrides System.Web.UI.Control
// Events
   public event EventHandler ServerChange;


System.Object System.Web.UI.Control(System.ComponentModel.IComponent, System.IDisposable, System.Web.UI.IParserAccessor, System.Web.UI.IDataBindingsAccessor) HtmlControl(System.Web.UI.IAttributeAccessor) HtmlContainerControl HtmlSelect(System.Web.UI.IPostBackDataHandler)

    Part I: Introduction to ASP.NET
    Part III: Namespace Reference
    Chapter 40. The System.Web.UI.MobileControls Namespace
    Chapter 42. The System.Web.UI.WebControls Namespace