System.Web.UI.HtmlControls.HtmlSelect.DataValueField Property

Gets or sets the field from the data source to bind to the System.Web.UI.WebControls.ListItem.Value property of each item in the System.Web.UI.HtmlControls.HtmlSelect control.

Syntax

[System.ComponentModel.DefaultValue("")]
public virtual string DataValueField { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

Use the HtmlSelect.DataValueField property to specify which field from the data source to bind to the System.Web.UI.WebControls.ListItem.Value property of each item in the control. This property is commonly used to provide a value for the System.Web.UI.WebControls.ListItem.Value property that differs from the value of the System.Web.UI.WebControls.ListItem.Text property.

The System.Web.UI.HtmlControls.HtmlSelect class provides two properties for specifying the data source to bind to. The HtmlSelect.DataSource property allows you to bind an System.Web.UI.HtmlControls.HtmlSelect control to any collection that implements the IEnumerable or System.ComponentModel.IListSource interfaces (such as System.Data.DataView, ArrayList, or List`1). When you use the HtmlSelect.DataSource property to specify the data source, you must explicitly call the System.Web.UI.Control.DataBind method to bind the control and its HtmlSelect.DataValueField property to the data source.

The HtmlSelect.DataSourceID property allows you to bind an System.Web.UI.HtmlControls.HtmlSelect control to a data source control that represents a data source. When you use the HtmlSelect.DataSourceID property to specify the data source, the System.Web.UI.HtmlControls.HtmlSelect control and its HtmlSelect.DataValueField property automatically bind to the data source control. Therefore, you do not need to explicitly call the System.Web.UI.Control.DataBind method.

Requirements

Namespace: System.Web.UI.HtmlControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0