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 方法。

適用於

另請參閱