共用方式為


BaseDataBoundControl.IsBoundUsingDataSourceID 屬性

定義

取得值,指出是否已設定 DataSourceID 屬性。

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

屬性值

如果 屬性設定為 以外的值, DataSourceID 則會傳回值 true ,否則值為 falseEmpty

範例

下列程式碼範例示範衍生資料繫結控制項類別如何使用 IsBoundUsingDataSourceID 屬性。 屬性 IsBoundUsingDataSourceID 用於方法實作中 PerformSelect ,以判斷是否 DataBinding 應該引發事件。 此程式碼範例是提供給 類別之較大範例的 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

備註

、、 DetailsView 和 等控制項會 IsBoundUsingDataSourceID 使用 屬性來判斷資料繫結控制項是否系結至 ASP.NET 2.0 資料來源控制項,例如 ObjectDataSourceSqlDataSourceGridViewMenuFormView

適用於

另請參閱