DataBoundControl.GetData Método
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Recupera um DataSourceView objeto que o controle associado a dados usa para executar 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
Retornos
O DataSourceView que o controle associado a dados usa para executar operações de dados. Se a DataMember propriedade estiver definida, um nome específico DataSourceView será retornado; caso contrário, o padrão DataSourceView será retornado.
Exceções
As propriedades e DataSourceID as DataSource propriedades são definidas.
- ou -
A DataMember propriedade é definida, mas um DataSourceView objeto com esse nome não existe.
Exemplos
O exemplo de código a seguir demonstra como o GetData método é chamado para recuperar o DataSourceView objeto do controle da fonte de dados associado e 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
Comentários
O GetData método recupera um DataSourceView objeto do controle de fonte de dados associado chamando o GetDataSource método. Se a DataSource propriedade for usada para identificar uma fonte de dados, um objeto padrão DataSourceView será criado.