HtmlSelect.DataValueField Property
Assembly: System.Web (in system.web.dll)
public: virtual property String^ DataValueField { String^ get (); void set (String^ value); }
/** @property */ public String get_DataValueField () /** @property */ public void set_DataValueField (String value)
public function get DataValueField () : String public function set DataValueField (value : String)
Property Value
The field from the data source to bind to the ListItem.Value property of each item in the HtmlSelect control. The default value is an empty string (""), which indicates that the property has not been set.Use the DataValueField property to specify which field from the data source to bind to the ListItem.Value property of each item in the control. This property is commonly used to provide a value for the ListItem.Value property that differs from the value of the ListItem.Text property.
The HtmlSelect class provides two properties for specifying the data source to bind to. The DataSource property allows you to bind an HtmlSelect control to any object that implements the IEnumerable or IListSource interfaces (such as DataView, ArrayList, or Hashtable). When you use the DataSource property to specify the data source, you must explicitly call the DataBind method to bind the control and its DataValueField property to the data source.
The DataSourceID property allows you to bind an HtmlSelect control to a data source control that represents a data source. When you use the DataSourceID property to specify the data source, the HtmlSelect control and its DataValueField property automatically bind to the data source control. Therefore, you do not need to explicitly call the DataBind method.
The following code example demonstrates how to use the DataSource and DataValueField properties to specify the field from the data source to bind to the ListItem.Value property of each item in the HtmlSelect control.
The following code example demonstrates how to use the DataSourceID and DataValueField properties to specify the field from the data source to bind to the ListItem.Value property of each item in the HtmlSelect control.
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.