DataBoundControl.MarkAsDataBound Método

Definição

Define o estado do controle em estado de exibição como associado com êxito aos dados.

protected:
 void MarkAsDataBound();
protected void MarkAsDataBound ();
member this.MarkAsDataBound : unit -> unit
Protected Sub MarkAsDataBound ()

Exemplos

O exemplo de código a seguir demonstra como o MarkAsDataBound método é usado por uma classe de controle associada a dados derivada. Depois que os GetData dados são recuperados pelo método e associados ao controle com o PerformDataBinding método, a RequiresDataBinding propriedade é definida false e o MarkAsDataBound método é chamado para sinalizar que o controle concluiu a associação e não a requer mais durante o ciclo de vida da página atual. 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 controle associado a dados mantém um valor no estado de exibição que indica se ele está atualmente associado a dados. O MarkAsDataBound método define o valor como true.

Aplica-se a

Confira também