BaseDataBoundControl.IsBoundUsingDataSourceID Właściwość

Definicja

Pobiera wartość wskazującą, czy właściwość jest ustawiona DataSourceID .

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

Wartość właściwości

Wartość true jest zwracana, jeśli DataSourceID właściwość jest ustawiona na wartość inną niż Empty; w przeciwnym razie wartość to false.

Przykłady

Poniższy przykład kodu pokazuje, jak IsBoundUsingDataSourceID właściwość jest używana przez pochodną klasę kontrolki powiązanej z danymi. Właściwość IsBoundUsingDataSourceID jest używana w implementacji PerformSelect metody w celu określenia, czy DataBinding zdarzenie powinno zostać podniesione. 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

Kontrolki, takie jak GridView, DetailsView, FormViewi Menu używają IsBoundUsingDataSourceID właściwości, aby określić, czy powiązana z danymi kontrolka jest powiązana z kontrolką źródła danych ASP.NET 2.0, taką jak lub ObjectDataSourceSqlDataSource.

Dotyczy

Zobacz też