Sdílet prostřednictvím


BaseDataBoundControl.RequiresDataBinding Vlastnost

Definice

Získá nebo nastaví hodnotu určující, zda DataBind() metoda má být volána.

protected:
 property bool RequiresDataBinding { bool get(); void set(bool value); };
protected bool RequiresDataBinding { get; set; }
member this.RequiresDataBinding : bool with get, set
Protected Property RequiresDataBinding As Boolean

Hodnota vlastnosti

Vrácená hodnota je true , pokud by metoda ovládacího prvku DataBind() vázaného na data měla být volána před vykreslením ovládacího prvku; jinak je falsehodnota .

Příklady

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

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

Pokud vlastnost nastavíte RequiresDataBinding tak, že true ovládací prvek vázané na data již začal vykreslovat jeho výstup na stránku, aktuální požadavek HTTP není zpětné volání a používáte DataSourceID vlastnost k identifikaci správy zdroje dat, ke které se má vytvořit vazba, DataBind metoda se volá okamžitě. V tomto případě RequiresDataBinding není vlastnost ve skutečnosti nastavena na true.

Platí pro

Viz také