DataBoundControl.PerformSelect 方法

定义

从关联的数据源中检索数据。Retrieves data from the associated data source.

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

示例

下面的代码示例演示如何重写PerformSelect方法以GetData使用方法从关联的数据源中检索数据, 并将其绑定到控件的元素。The following code example demonstrates how to override the PerformSelect method to retrieve data from an associated data source using the GetData method and bind it to the elements of the control. 此代码示例是为DataBoundControl类提供的更大示例的一部分。This code example is part of a larger example provided for the DataBoundControl class.

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

注解

检索数据以将数据绑定到数据绑定控件的元素后, 将调用方法。PerformDataBindingThe PerformDataBinding method is called after data is retrieved to bind data to elements of the data-bound control. 派生类型重写此方法, 以便仅在默认实现不足的情况下检索数据。Derived types override this method to retrieve data only if the default implementation is not adequate. 通常, 足以提供一个DataSourceViewSelectCallback委托来执行任何自定义数据工作, 而不是PerformDataBinding实现方法。Typically, it is sufficient to provide a DataSourceViewSelectCallback delegate that performs any custom data work, rather than implementing the PerformDataBinding method.

适用于

另请参阅