BaseDataBoundControl.IsBoundUsingDataSourceID Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает значение, указывающее, задано ли DataSourceID свойство.
protected:
property bool IsBoundUsingDataSourceID { bool get(); };
protected bool IsBoundUsingDataSourceID { get; }
member this.IsBoundUsingDataSourceID : bool
Protected ReadOnly Property IsBoundUsingDataSourceID As Boolean
Значение свойства
Значение возвращается, если для true свойства задано значение, отличное Emptyот ; в противном случае значение равноfalse.DataSourceID
Примеры
В следующем примере кода показано, как 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
Комментарии
Такие элементы управления, как GridView, DetailsViewFormViewи Menu используйте IsBoundUsingDataSourceID свойство, чтобы определить, привязан ли элемент управления с привязкой к данным ASP.NET 2.0, например ObjectDataSource илиSqlDataSource.