DataBoundControl.GetData Metoda

Definicja

Pobiera obiekt używany przez kontrolkę związaną DataSourceView z danymi do wykonywania operacji na danych.

protected:
 virtual System::Web::UI::DataSourceView ^ GetData();
protected virtual System.Web.UI.DataSourceView GetData ();
abstract member GetData : unit -> System.Web.UI.DataSourceView
override this.GetData : unit -> System.Web.UI.DataSourceView
Protected Overridable Function GetData () As DataSourceView

Zwraca

Kontrolka DataSourceView powiązana z danymi używa do wykonywania operacji na danych. DataMember Jeśli właściwość jest ustawiona, zostanie zwrócona określona nazwa o nazwieDataSourceView. W przeciwnym razie zostanie zwrócona wartość domyślnaDataSourceView.

Wyjątki

DataSource Właściwości i DataSourceID są ustawione.

-lub-

Właściwość DataMember jest ustawiana, ale DataSourceView obiekt o tej nazwie nie istnieje.

Przykłady

W poniższym przykładzie kodu pokazano, jak GetData metoda jest wywoływana w celu pobrania DataSourceView obiektu ze skojarzonej kontroli źródła danych, a Select metoda jest wywoływana w celu pobrania danych. Ten przykład kodu jest częścią większego przykładu udostępnionego 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 GetData pobiera DataSourceView obiekt ze skojarzonej kontroli źródła danych przez wywołanie GetDataSource metody . DataSource Jeśli właściwość jest używana do identyfikowania źródła danych, tworzony jest obiekt domyślnyDataSourceView.

Dotyczy

Zobacz też