BaseDataBoundControl.IsBoundUsingDataSourceID Egenskap

Definition

Hämtar ett värde som anger om egenskapen DataSourceID har angetts.

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

Egenskapsvärde

Värdet true returneras om egenskapen DataSourceID är inställd på ett annat värde än Empty. Annars är falsevärdet .

Exempel

Följande kodexempel visar hur egenskapen IsBoundUsingDataSourceID används av en härledd databunden kontrollklass. Egenskapen IsBoundUsingDataSourceID används i metodimplementeringen PerformSelect för att avgöra om händelsen DataBinding ska utlösas. Det här kodexemplet är en del av ett större exempel för DataBoundControl klassen.

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

Kommentarer

Kontroller som GridView, DetailsView, FormView och Menu använder egenskapen IsBoundUsingDataSourceID för att avgöra om den databundna kontrollen är bunden till en ASP.NET 2.0-datakällkontroll, till exempel en ObjectDataSource eller SqlDataSource.

Gäller för

Se även