BaseDataBoundControl.DataBind BaseDataBoundControl.DataBind BaseDataBoundControl.DataBind BaseDataBoundControl.DataBind Method

定义

将数据源绑定到被调用的服务器控件及其所有子控件。Binds a data source to the invoked server control and all its child controls.

public:
 override void DataBind();
public override void DataBind ();
override this.DataBind : unit -> unit
Public Overrides Sub DataBind ()

注解

类将重写方法, 以标识数据绑定控件绑定到的数据源并生成适当的控件树。 DataBind BaseDataBoundControlThe BaseDataBoundControl class overrides the DataBind method to identify the data source that the data-bound control binds to and builds the appropriate control trees. 解析数据源时, 由DataSourceID属性标识的数据源优先。When resolving the data source, the data source identified by the DataSourceID property takes precedence. 如果DataSourceID未设置, 则使用DataSource由属性标识的对象。If DataSourceID is not set, the object identified by the DataSource property is used.

DataBind方法在派生自BaseDataBoundControl的所有 ASP.NET 数据绑定控件上是密封的。The DataBind method is sealed on all ASP.NET data-bound controls derived from BaseDataBoundControl. DataBoundControl从和HierarchicalDataBoundControl类派生的数据绑定控件应重写PerformDataBinding方法, 而不是DataBind方法来绑定数据。Data-bound controls derived from the DataBoundControl and HierarchicalDataBoundControl classes should override the PerformDataBinding method instead of the DataBind method to bind data. 如果DataBind重写, 则OnDataBindingOnDataBound事件将按顺序引发。If DataBind is overridden, the OnDataBinding and OnDataBound events are raised out of order.

适用于

另请参阅