DataBoundControl.PerformSelect メソッド

定義

関連付けられているデータ ソースからデータを取得します。

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

次のコード例では、GetData メソッドを使用して関連付けられたデータ ソースからデータを取得し、それをコントロールの要素にバインドするために、PerformSelect メソッドをオーバーライドする方法を示します。 このコード例は、 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 メソッドは、データを取得してデータバインド コントロールの要素にデータをバインドした後に呼び出されます。 派生型は、既定の実装が適切でない場合にのみ、このメソッドをオーバーライドしてデータを取得します。 通常、PerformDataBinding メソッドを実装するのではなく、カスタム データ処理を実行するDataSourceViewSelectCallbackデリゲートを提供するだけで十分です。

適用対象

こちらもご覧ください