System.Web.UI.WebControls Namespace BaseDataList Class
Sets or retrieves the source containing a list of values used to populate the items within the control.
Inline |
<asp:basedatalist datasource = enumerable ... > |
Script |
BaseDataList.DataSource [ = enumerable ] |
enumerable |
An IEnumerable or IListSource that contains a collection of values used to supply data to bind to the control. |
The property is read/write with no default value.
Use the DataSource property to specify the source of values to bind to a data listing control.
A data source must be an object that implements either the IEnumerable or the IListSource interface to bind to a control derived from the BaseDataList class. When you set the DataSource property, you must manually write the code to perform data binding.
If the data source specified by the DataSource property contains multiple sources of data, use the DataMember property to identify the specific source to bind to the control. For example, if you have a DataSet object with multiple tables, you must specify which table to bind to the control. After you have specified the data source, use the DataBind method to bind the data source to the control.
Alternately, with version 2.0, you can use the DataSourceID property to automatically bind to a data source represented by a data source control. When you set the DataSourceID property, the data listing control automatically binds to the specified data source control. You do not need to write code that explicitly calls the DataBind method.
If values are specified for both the DataSource property and the DataSourceID property, ASP.NET is not able to resolve the data source and a System.Web.HttpException exception is thrown.
This property cannot be set by themes or style sheet themes.
The following examples demonstrate how to use the DataSource property to specify different types of data sources.
BaseDataList Members DataMember DataKeyField DataKeys