DataBoundControl.MarkAsDataBound Methode

Definition

Legt den Zustand des Steuerelements im Ansichtszustand als erfolgreich an Daten gebunden fest.

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

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie die MarkAsDataBound Methode von einer abgeleiteten datengebundenen Steuerelementklasse verwendet wird. Nachdem Daten von der GetData Methode abgerufen und an das Steuerelement mit der PerformDataBinding Methode gebunden sind, wird die Eigenschaft false festgelegt und die MarkAsDataBound Methode aufgerufen, um zu signalisieren, RequiresDataBinding dass das Steuerelement die Bindung abgeschlossen hat und während des Lebenszyklus der aktuellen Seite nicht mehr benötigt wird. Dieses Codebeispiel ist Teil eines größeren Beispiels, das für die DataBoundControl Klasse bereitgestellt wird.

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

Hinweise

Das datengebundene Steuerelement verwaltet einen Wert im Ansichtszustand, der angibt, ob es derzeit an Daten gebunden ist. Die MarkAsDataBound Methode legt den Wert auf true.

Gilt für

Siehe auch