DataBoundControl.PerformSelect Metoda

Definicja

Pobiera dane ze skojarzonego źródła danych.

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

Przykłady

W poniższym przykładzie kodu pokazano, jak zastąpić PerformSelect metodę pobierania danych ze skojarzonego źródła danych przy użyciu GetData metody i powiązać ją z elementami kontrolki. Ten przykład kodu jest częścią większego przykładu podanego DataBoundControl dla klasy.

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

Uwagi

Metoda jest wywoływana PerformDataBinding po pobraniu danych w celu powiązania danych z elementami kontrolki powiązanej z danymi. Typy pochodne zastępują tę metodę w celu pobrania danych tylko wtedy, gdy implementacja domyślna nie jest odpowiednia. Zazwyczaj wystarczy dostarczyć delegata, który wykonuje dowolną niestandardową DataSourceViewSelectCallback pracę z danymi, zamiast implementować metodę PerformDataBinding .

Dotyczy

Zobacz też