Export (0) Print
Expand All

Repeater.DataSourceID Property

Note: This property is new in the .NET Framework version 2.0.

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:
virtual property String^ DataSourceID {
	String^ get ();
	void set (String^ value);
}
/** @property */
public String get_DataSourceID ()

/** @property */
public void set_DataSourceID (String value)

public function get DataSourceID () : String

public function set DataSourceID (value : String)

Property Value

The ID property of the data source control.

Exception typeCondition

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 an object that implements the System.Collections.IEnumerable interface (such as the System.Data.DataView, System.Collections.ArrayList, or System.Collections.Hashtable 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.

TopicLocation
How to: Add Repeater Web Server Controls to a Web Forms Page (Visual Studio)Building ASP .NET Web Applications in Visual Studio

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.

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft