HtmlSelect::DataMember Property

 

Gets or sets the set of data to bind to the HtmlSelect control from a DataSource property with multiple sets of data.

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

public:
property String^ DataMember {
	virtual String^ get();
	virtual void set(String^ value);
}

Property Value

Type: System::String^

The set of data to bind to the HtmlSelect control from a DataSource with multiple sets of data. The default value is an empty string (""), which indicates the property has not been set.

Exception Condition
HttpException

The DataMember property is set during the data-binding phase of the HtmlSelect control.

If the DataSource property contains multiple sets of data, use the DataMember property to specify which set of data to bind to the control. For example, if you have a System.Data::DataSet object with multiple tables, use this property to indicate which table to bind to the control.

After you have specified the data source to bind to the control, you 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.

The following code example demonstrates how to use the DataMember property to specify a set of data to bind to the HtmlSelect control from a DataSource property with multiple sets of data.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: