BaseDataBoundControl.OnDataBound メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim e As EventArgs Me.OnDataBound(e)

このメソッドは、サーバー コントロールに、データ バインディング論理とコントロールの関連付けが完了したことを通知します。
![]() |
---|
BaseDataBoundControl から派生したすべてのコントロールには DataBind メソッドがシールされています。データ バインド コントロールでは、データをバインドするために DataBind メソッドではなく、PerformDataBinding メソッドをオーバーライドする必要があります。DataBind をオーバーライドすると、OnDataBinding イベントと OnDataBound イベントが不正な順序で発生します。 |
イベントが発生すると、デリゲートを使用してイベント ハンドラが呼び出されます。詳細については、「イベントの発生」を参照してください。
OnDataBound メソッドを使用すると、デリゲートを結び付けずに、派生クラスでイベントを処理することもできます。派生クラスでイベントを処理する場合は、この手法をお勧めします。
継承時の注意 派生クラスで OnDataBound をオーバーライドする場合は、登録されているデリゲートがイベントを受け取ることができるように、基本クラスの OnDataBound メソッドを必ず呼び出してください。
OnDataBound メソッドを使用して、派生データ バインド コントロール クラスにより DataBound イベントを発生させる方法を、次のコード例に示します。GetData メソッドおよび PerformDataBinding メソッドを使用してデータをコントロールにバインドした後、データ バインド コントロールは DataBound イベントを発生させて、データ バインディングが完了したことを通知します。このコード例は、DataBoundControl クラスのトピックで取り上げているコード例の一部分です。
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 'PerformSelect
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); }

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からBaseDataBoundControl.OnDataBound メソッドを検索する場合は、下記のリンクをクリックしてください。

- BaseDataBoundControl.OnDataBound メソッドのページへのリンク