DataBoundControl.GetData Método

Definição

Recupera um DataSourceView objeto que o controlo data-bound utiliza para realizar operações de dados.

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

Devoluções

O DataSourceView que o controlo de dados limitado utiliza para realizar operações de dados. Se a DataMember propriedade for definida, um nome DataSourceView específico é devolvedo; caso contrário, o padrão DataSourceView é devolvido.

Exceções

Ambas as DataSource propriedades e DataSourceID estão definidas.

-ou-

A DataMember propriedade é definida, mas um DataSourceView objeto com esse nome não existe.

Exemplos

O exemplo de código seguinte demonstra como o GetData método é chamado para recuperar o DataSourceView objeto do controlo de fonte de dados associado e como o Select método é chamado para recuperar os dados. Este exemplo de código faz parte de um exemplo maior fornecido para a DataBoundControl classe.

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

Observações

O GetData método recupera um DataSourceView objeto do controlo de fonte de dados associado, chamando o GetDataSource método. Se a DataSource propriedade for usada para identificar uma fonte de dados, é criado um objeto por defeito DataSourceView .

Aplica-se a

Ver também