Compartir por


DataBoundControl.GetData Método

Definición

Recupera un DataSourceView objeto que el control enlazado a datos usa para realizar operaciones de datos.

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

que DataSourceView usa el control enlazado a datos para realizar operaciones de datos. Si se establece la DataMember propiedad , se devuelve un nombre específico DataSourceView ; de lo contrario, se devuelve el valor predeterminado DataSourceView .

Excepciones

Se establecen las DataSource propiedades y DataSourceID .

O bien

La DataMember propiedad se establece pero no existe un DataSourceView objeto por ese nombre.

Ejemplos

En el GetData ejemplo de código siguiente se muestra cómo se llama al método para recuperar el DataSourceView objeto del control de origen de datos asociado y Select se llama al método para recuperar los datos. Este ejemplo de código forma parte de un ejemplo más grande proporcionado para la DataBoundControl clase .

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

Comentarios

El GetData método recupera un DataSourceView objeto del control de origen de datos asociado llamando al GetDataSource método . Si la DataSource propiedad se usa para identificar un origen de datos, se crea un objeto predeterminado DataSourceView .

Se aplica a

Consulte también