DataBoundControl.MarkAsDataBound Metod

Definition

Anger tillståndet för kontrollen i visningstillståndet som korrekt bundet till data.

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

Exempel

Följande kodexempel visar hur MarkAsDataBound metoden används av en härledd databunden kontrollklass. När data hämtas med GetData metoden och binds till kontrollen med PerformDataBinding metoden RequiresDataBinding anges egenskapen till false och MarkAsDataBound metoden anropas för att signalera att kontrollen har slutfört bindningen och inte längre kräver den under den aktuella sidans livscykel. Det här kodexemplet är en del av ett större exempel för DataBoundControl klassen.

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

Kommentarer

Den databundna kontrollen upprätthåller ett värde i visningstillstånd som anger om den för närvarande är bunden till data. Metoden MarkAsDataBound anger värdet till true.

Gäller för

Se även