DataBoundControl.MarkAsDataBound Metoda

Definice

Nastaví stav ovládacího prvku ve stavu zobrazení jako úspěšně svázaný s daty.

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

Příklady

Následující příklad kódu ukazuje, jak MarkAsDataBound metoda používá odvozenou třídu ovládacího prvku vázaného na data. Po načtení dat metodou GetData a vázán na ovládací prvek s PerformDataBinding metodou, RequiresDataBinding vlastnost je nastavena na false a MarkAsDataBound metoda je volána k signálu, že ovládací prvek dokončil vazbu a už ji nevyžaduje během životního cyklu aktuální stránky. Tento příklad kódu je součástí většího příkladu poskytnutého DataBoundControl pro třídu.

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

Poznámky

Ovládací prvek svázaný s daty udržuje hodnotu ve stavu zobrazení, která označuje, jestli je aktuálně svázaná s daty. Metoda MarkAsDataBound nastaví hodnotu na true.

Platí pro

Viz také