asp.net.ph

HtmlSelect.DataSource Property

System.Web.UI.HtmlControls Namespace   HtmlSelect Class


Sets or retrieves the source of information to bind to the HtmlSelect control.

Syntax


Inline <select datasource = enumerable ... >
Script HtmlSelect.DataSource [ = enumerable ]

Property Value


enumerable An IEnumerable collection that contains the data to bind to the control.

The property is read/write with no default value.

Remarks

Use the DataSource property to specify the source of the data to bind to the HtmlSelect control.

NOTE: The data source must be an object that implements the System.Collections.IEnumerable interface, such as a DataView, an ArrayList, or a Hashtable.

If the data source contains a single column or field, the records in the data source are then automatically used to populate the option elements of the select box.

If the data source contains multiple sets of data, such as a DataSet with multiple tables, use the DataMember property to specify which table in the data source to bind to the control.

You can also bind the HtmlSelect to a data source that contains multiple columns or fields. In this case, you 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.

Example

The following example demonstrates how to programmatically set the DataSource property at run time to specify the source of information to bind to the HtmlSelect control.

mySelect.DataSource = myDataSet.Tables [ "Types" ].DefaultView;

 Show me 

See Also

HtmlSelect Members   DataTextField   DataValueField   DataMember Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph