BaseDataList.DataSourceID BaseDataList.DataSourceID BaseDataList.DataSourceID BaseDataList.DataSourceID Property

定义

获取或设置数据源控件的 ID 属性,数据列表控件应使用它来检索其数据源。Gets or sets the ID property of the data source control that the data listing control should use to retrieve its data source.

public:
 virtual property System::String ^ DataSourceID { System::String ^ get(); void set(System::String ^ value); };
[System.Web.UI.Themeable(false)]
public virtual string DataSourceID { get; set; }
member this.DataSourceID : string with get, set
Public Overridable Property DataSourceID As String

属性值

分配给数据源控件的编程标识符。The programmatic identifier assigned to the data source control.

异常

无法解析数据源,因为对 DataSource 属性和 DataSourceID 属性指定了同一个值。The data source cannot be resolved because a value is specified for both the DataSource property and the DataSourceID property.

注解

使用DataSourceID属性来访问ID数据列表控件应使用它来检索其数据源的数据源控件的属性。Use the DataSourceID property to access the ID property of the data source control that the data listing control should use to retrieve its data source. 数据源引用的控件DataSourceID属性可以是任何实现控件IDataSource接口。The data source control 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 data listing control that references it, or in a parent control of the data listing control. 当指定此属性的值时,数据列表控件自动将绑定到指定的数据源控件。When you specify a value for this property, the data listing control automatically binds to the specified data source control. 不需要编写代码显式调用DataBind方法。You do not need to write code that explicitly calls the DataBind method.

或者,可以使用DataSource属性来指定要绑定到数据列表控件的值的源。Alternately, you can use the DataSource property to specify the source of values to bind to a data listing control. 数据源必须实现的集合System.Collections.IEnumerable接口 (如System.Data.DataViewSystem.Collections.ArrayList,或System.Collections.Generic.List<T>) 或IListSource界面以绑定到控件派生自BaseDataList类。The data source must be a collection that implements the System.Collections.IEnumerable interface (such as System.Data.DataView, System.Collections.ArrayList, or System.Collections.Generic.List<T>) or the IListSource interface to bind to a control derived from the BaseDataList class. 当您将设置DataSource属性时,必须手动编写代码来执行数据绑定。When you set the DataSource property, you must manually write the code to perform data binding.

如果两个指定值DataSource属性和DataSourceID属性,则 ASP.NET 将无法解析数据源和一个System.Web.HttpException引发异常。If values are specified for both the DataSource property and the DataSourceID property, ASP.NET is not able to resolve the data source and an System.Web.HttpException exception is thrown.

无法通过主题或样式表主题设置此属性。This property cannot be set by themes or style sheet themes. 有关详细信息,请参阅ThemeableAttributeASP.NET 主题和外观For more information, see ThemeableAttribute and ASP.NET Themes and Skins.

适用于

另请参阅