BaseDataList.DataSourceID 属性

定义

获取或设置数据源控件的 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; }
[<System.Web.UI.Themeable(false)>]
member this.DataSourceID : string with get, set
Public Overridable Property DataSourceID As String

属性值

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 可以是实现该接口的任何控件 IDataSourceThe 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. 无需编写显式调用方法的代码 DataBindYou 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.ArrayListSystem.Collections.Generic.List<T>) 或 IListSource 接口绑定到从类派生的控件 BaseDataListThe 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.

适用于

另请参阅