HtmlSelect::DataValueField Property
Gets or sets the field from the data source to bind to the ListItem::Value property of each item in the HtmlSelect control.
Assembly: System.Web (in System.Web.dll)
public: virtual property String^ DataValueField { String^ get (); void set (String^ value); }
<asp:HtmlSelect DataValueField="String" />
Property Value
Type: System::StringThe 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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.