Sdílet prostřednictvím


BaseDataBoundControl.IsBoundUsingDataSourceID Vlastnost

Definice

Získá hodnotu určující, zda DataSourceID je vlastnost nastavena.

protected:
 property bool IsBoundUsingDataSourceID { bool get(); };
protected bool IsBoundUsingDataSourceID { get; }
member this.IsBoundUsingDataSourceID : bool
Protected ReadOnly Property IsBoundUsingDataSourceID As Boolean

Hodnota vlastnosti

Hodnota true se vrátí, pokud DataSourceID je vlastnost nastavena na jinou hodnotu než Empty; jinak je falsehodnota .

Příklady

Následující příklad kódu ukazuje, jak IsBoundUsingDataSourceID vlastnost je používán odvozenou data-bound control třídy. Vlastnost IsBoundUsingDataSourceID se používá v PerformSelect implementaci metody k určení, zda DataBinding má být událost vyvolána. 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

Ovládací prvky, jako GridViewje , DetailsView, FormViewa Menu použít IsBoundUsingDataSourceID vlastnost k určení, zda je ovládací prvek svázaný s ASP.NET 2.0 ovládací prvek zdroje dat, například nebo ObjectDataSourceSqlDataSource.

Platí pro

Viz také