asp.net.ph

BaseDataList.DataSource Property

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.

Syntax


Inline <asp:basedatalist datasource = enumerable ... >
Script BaseDataList.DataSource [ = enumerable ]

Property Value


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.

Remarks

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.

Example

The following examples demonstrate how to use the DataSource property to specify different types of data sources.

Using a DropDownList in an Editable DataList
Run Sample | View Source
Using the Built-In Pager with Custom Navigation Controls
Run Sample | View Source
Basic Nested Templated Controls Example
Run Sample | View Source
See Also

BaseDataList Members   DataMember   DataKeyField   DataKeys 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