Condividi tramite


BaseDataBoundControl.IsBoundUsingDataSourceID Proprietà

Definizione

Ottiene un valore che indica se la DataSourceID proprietà è impostata.

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

Valore della proprietà

Il valore true viene restituito se la DataSourceID proprietà è impostata su un valore diverso da Empty; in caso contrario, il valore è false.

Esempio

Nell'esempio di codice seguente viene illustrato come la IsBoundUsingDataSourceID proprietà viene utilizzata da una classe di controllo associata a dati derivata. La IsBoundUsingDataSourceID proprietà viene utilizzata nell'implementazione del PerformSelect metodo per determinare se l'evento DataBinding deve essere generato. Questo esempio di codice fa parte di un esempio più ampio fornito per la DataBoundControl classe .

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

Commenti

Controlli come , , e usano la IsBoundUsingDataSourceID proprietà per determinare se il controllo associato a dati è associato a un controllo origine dati ASP.NET 2.0, ad esempio o SqlDataSourceObjectDataSource .MenuFormViewDetailsViewGridView

Si applica a

Vedi anche