DataBoundControl.MarkAsDataBound Metoda

Definicja

Ustawia stan kontrolki w stanie widoku jako pomyślnie powiązany z danymi.

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

Przykłady

W poniższym przykładzie kodu pokazano, jak MarkAsDataBound metoda jest używana przez pochodną klasę kontrolki powiązanej z danymi. Po pobraniu danych przez GetData metodę i powiązaniu z kontrolką PerformDataBinding za pomocą metody RequiresDataBinding właściwość jest ustawiona na false , a MarkAsDataBound metoda jest wywoływana w celu sygnalizowania, że kontrolka zakończyła powiązanie i nie wymaga jej już podczas cyklu życia bieżącej strony. Ten przykład kodu jest częścią większego przykładu podanego DataBoundControl dla klasy.

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

Uwagi

Kontrolka powiązana z danymi zachowuje wartość w stanie widoku, która wskazuje, czy jest ona obecnie powiązana z danymi. Metoda MarkAsDataBound ustawia wartość na true.

Dotyczy

Zobacz też