DataBoundControl.GetData DataBoundControl.GetData DataBoundControl.GetData DataBoundControl.GetData Method

Definición

Recupera un objeto DataSourceView que el control enlazado a datos usa para llevar a cabo operaciones de datos.Retrieves a DataSourceView object that the data-bound control uses to perform data operations.

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

Devoluciones

El objeto DataSourceView que utiliza el control enlazado a datos para realizar operaciones con los datos.The DataSourceView that the data-bound control uses to perform data operations. Si se establece la propiedad DataMember, se devuelve un objeto DataSourceView concreto con nombre; de lo contrario, se devuelve el DataSourceView predeterminado.If the DataMember property is set, a specific, named DataSourceView is returned; otherwise, the default DataSourceView is returned.

Excepciones

Se establecen las propiedades DataSource y DataSourceID.Both the DataSource and DataSourceID properties are set.

o bien-or- Se establece la propiedad DataMember, pero no existe un objeto DataSourceView con ese nombre.The DataMember property is set but a DataSourceView object by that name does not exist.

Ejemplos

En el ejemplo de código siguiente se GetData muestra cómo se llama al método DataSourceView para recuperar el objeto del control de origen de Select datos asociado y se llama al método para recuperar los datos.The following code example demonstrates how the GetData method is called to retrieve the DataSourceView object from the associated data source control and the Select method is called to retrieve the data. Este ejemplo de código forma parte de un ejemplo más extenso proporcionado DataBoundControl para la clase.This code example is part of a larger example provided for the DataBoundControl class.

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 'PerformSelect

Comentarios

El GetData método recupera un DataSourceView objeto del control de origen de datos asociado llamando al GetDataSource método.The GetData method retrieves a DataSourceView object from the associated data source control by calling the GetDataSource method. Si la DataSource propiedad se utiliza para identificar un origen de datos, se DataSourceView crea un objeto predeterminado.If the DataSource property is used to identify a data source, a default DataSourceView object is created.

Se aplica a

Consulte también: