DataBoundControl.PerformSelect 方法

定义

从关联的数据源中检索数据。

protected:
 override void PerformSelect();
protected override void PerformSelect ();
override this.PerformSelect : unit -> unit
Protected Overrides Sub PerformSelect ()

示例

下面的代码示例演示如何重写 PerformSelect 该方法,以使用 GetData 该方法从关联的数据源检索数据,并将其绑定到控件的元素。 此代码示例是为类提供的大型示例的 DataBoundControl 一部分。

protected override void PerformSelect() {            

   // Call OnDataBinding here if bound to a data source using the
   // DataSource property (instead of a DataSourceID), because the
   // databinding statement is evaluated before the call to GetData.       
    if (! IsBoundUsingDataSourceID) {
        OnDataBinding(EventArgs.Empty);
    }            
    
    // The GetData method retrieves the DataSourceView object from  
    // the IDataSource associated with the data-bound control.            
    GetData().Select(CreateDataSourceSelectArguments(), 
        OnDataSourceViewSelectCallback);
    
    // The PerformDataBinding method has completed.
    RequiresDataBinding = false;
    MarkAsDataBound();
    
    // Raise the DataBound event.
    OnDataBound(EventArgs.Empty);
}
Protected Overrides Sub PerformSelect()

    ' Call OnDataBinding here if bound to a data source using the 
    ' DataSource property (instead of a DataSourceID) because the 
    ' data-binding statement is evaluated before the call to GetData.
    If Not IsBoundUsingDataSourceID Then
        OnDataBinding(EventArgs.Empty)
    End If

    ' The GetData method retrieves the DataSourceView object from the 
    ' IDataSource associated with the data-bound control.            
    GetData().Select(CreateDataSourceSelectArguments(), _
        AddressOf OnDataSourceViewSelectCallback)

    ' The PerformDataBinding method has completed.
    RequiresDataBinding = False
    MarkAsDataBound()

    ' Raise the DataBound event.
        OnDataBound(EventArgs.Empty)

End Sub

注解

PerformDataBinding在检索数据以将数据绑定到数据绑定控件的元素之后调用该方法。 仅当默认实现不够时,派生类型才会重写此方法以检索数据。 通常,它足以提供执行 DataSourceViewSelectCallback 任何自定义数据工作的委托,而不是实现 PerformDataBinding 该方法。

适用于

另请参阅