Freigeben über


BaseDataBoundControl.IsBoundUsingDataSourceID Eigenschaft

Definition

Ruft einen Wert ab, der angibt, ob die DataSourceID Eigenschaft festgelegt ist.

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

Eigenschaftswert

Der Wert true wird zurückgegeben, wenn die DataSourceID Eigenschaft auf einen anderen Wert als Empty; andernfalls ist falseder Wert .

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie die IsBoundUsingDataSourceID Eigenschaft von einer abgeleiteten datengebundenen Steuerelementklasse verwendet wird. Die IsBoundUsingDataSourceID Eigenschaft wird in der PerformSelect Methodenimplementierung verwendet, um zu bestimmen, ob das DataBinding Ereignis ausgelöst werden soll. Dieses Codebeispiel ist Teil eines größeren Beispiels, das für die DataBoundControl Klasse bereitgestellt wird.

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

Hinweise

Steuerelemente wie , , und verwenden Sie die IsBoundUsingDataSourceID Eigenschaft, um zu bestimmen, ob das datengebundene Steuerelement an ein ASP.NET 2.0-Datenquellensteuerelement gebunden ist, z. B. ein oder SqlDataSource.ObjectDataSourceMenuFormViewDetailsViewGridView

Gilt für:

Weitere Informationen