DataBoundControl.PerformSelect Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Recupera dados da fonte de dados associada.
protected:
override void PerformSelect();
protected override void PerformSelect();
override this.PerformSelect : unit -> unit
Protected Overrides Sub PerformSelect ()
Exemplos
O exemplo de código seguinte demonstra como sobrescrever o PerformSelect método para recuperar dados de uma fonte de dados associada usando o GetData método e associá-lo aos elementos do controlo. 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 PerformDataBinding método é chamado após a recuperação dos dados para ligar os dados a elementos do controlo data-bound. Tipos derivados sobrepõem-se a este método para recuperar dados apenas se a implementação padrão não for adequada. Normalmente, basta fornecer um DataSourceViewSelectCallback delegado que realize qualquer trabalho personalizado de dados, em vez de implementar o PerformDataBinding método.