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

適用於

另請參閱