DataBoundControl.GetDataSource 方法

定义

检索与数据绑定控件关联的 IDataSource 接口(如果有)。Retrieves the IDataSource interface that the data-bound control is associated with, if any.

protected:
 virtual System::Web::UI::IDataSource ^ GetDataSource();
protected virtual System.Web.UI.IDataSource GetDataSource ();
abstract member GetDataSource : unit -> System.Web.UI.IDataSource
override this.GetDataSource : unit -> System.Web.UI.IDataSource
Protected Overridable Function GetDataSource () As IDataSource

返回

一个 IDataSource,表示由 DataSourceID 标识的数据源。An IDataSource that represents the data source identified by DataSourceID.

异常

当前容器中不存在由 DataSourceID 属性标识的控件。The control identified by the DataSourceID property does not exist in the current container.

-or- DataSourceID 属性标识的控件不实现 IDataSource 接口。The control identified by the DataSourceID property does not implement the IDataSource interface.

注解

方法在内部GetDataSource调用方法。 GetDataThe GetData method calls the GetDataSource method internally. 有效IDataSource的实例由这两个方法检索, 并DataBoundControl由对象缓存, 直到该OnDataPropertyChanged方法发出数据源已更改的信号。A valid IDataSource instance is retrieved by these two methods and is cached by the DataBoundControl object until the OnDataPropertyChanged method signals that the data source has changed.

适用于

另请参阅