Share via


DataBoundControl.MarkAsDataBound Méthode

Définition

Définit l'état du contrôle dans l'état d'affichage comme lié avec succès aux données.

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

Exemples

L’exemple de code suivant montre comment la MarkAsDataBound méthode est utilisée par une classe de contrôle liée aux données dérivée. Une fois les données récupérées par la GetData méthode et liées au contrôle avec la PerformDataBinding méthode, la RequiresDataBinding propriété est définie false et la MarkAsDataBound méthode est appelée pour signaler que le contrôle a terminé la liaison et qu’il ne l’exige plus pendant le cycle de vie de la page active. Cet exemple de code fait partie d’un exemple plus grand fourni pour la 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

Remarques

Le contrôle lié aux données conserve une valeur dans l’état d’affichage qui indique s’il est actuellement lié aux données. La MarkAsDataBound méthode définit la valeur truesur .

S’applique à

Voir aussi