Repeater::DataSourceID Property

 

Gets or sets the ID property of the data source control that the Repeater control should use to retrieve its data source.

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

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

Property Value

Type: System::String^

The ID property of the data source control.

Exception Condition
HttpException

The data source cannot be resolved for one of the following reasons:

  • A value is specified for both the DataSource and DataSourceID properties.

  • The data source specified by the DataSourceID property cannot be found on the page.

  • The data source specified by the DataSourceID property does not implement IDataSource.

Use the DataSourceID property to access the ID property of the data source control that the Repeater control should use to retrieve its data source. The data source control that is referenced by the DataSourceID property can be any control that implements the IDataSource interface. The data source control must exist either in the same naming container as the Repeater control that references it or in a parent control of the Repeater control. When you specify a value for the DataSourceID property, the Repeater control binds to the specified data source control. You do not need to write code that explicitly calls the DataBind method.

Alternatively, you can use the DataSource property to specify the source of values to bind to the Repeater control. The data source must be a collection that implements the System.Collections::IEnumerable interface (such as the System.Data::DataView or System.Collections::ArrayList object) or the IListSource interface. When you set the DataSource property, you must write the code to perform the data binding.

If values are specified for both the DataSource and DataSourceID properties, ASP.NET is not able to resolve the data source and an System.Web::HttpException exception is thrown.

The value of this property is stored in view state.

The following code example demonstrates how to set the DataSourceID property to the ID property of a SqlDataSource control. When the page is loaded, the Repeater control binds to the data source that is specified by the SqlDataSource control and the data is displayed to the user.

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

.NET Framework
Available since 2.0
Return to top
Show: