DetailsViewDeletedEventArgs クラス
アセンブリ: System.Web (system.web.dll 内)


DetailsView コントロールは、コントロール内の Delete ボタン (CommandName プロパティが "Delete" に設定されたボタン) がクリックされた場合に、DetailsView コントロールが実際にレコードを削除した後に ItemDeleted イベントを発生させます。これにより、このイベントが発生するたびにカスタム ルーチン (削除操作の結果を確認するなど) を実行するイベント ハンドラを提供できます。
DetailsViewDeletedEventArgs オブジェクトがイベント ハンドラに渡され、これにより影響を受けたレコード数および発生した例外を確認できます。削除操作の影響を受けたレコード数を確認するには、AffectedRows プロパティを使用します。例外が発生しているかどうかを確認するには、Exception プロパティを使用します。ExceptionHandled プロパティを設定することにより、イベント ハンドラで既に例外が処理されたかどうかを示すこともできます。削除されたレコードのキー フィールドおよびキー以外のフィールドの名前と値のペアにアクセスする場合は、Keys プロパティ (名前の場合) と Values プロパティ (値の場合) を使用します。
イベント処理の詳細については、「イベントの利用」を参照してください。
DetailsViewDeletedEventArgs クラスのインスタンスの初期プロパティ値の一覧については、DetailsViewDeletedEventArgs コンストラクタのトピックを参照してください。

ItemDeleted イベントのイベント ハンドラに渡された DetailsViewDeletedEventArgs オブジェクトを使用して、削除操作中に例外が発生したかどうかを確認する方法のコード例を次に示します。
<%@ Page language="VB" AutoEventWireup="False" %> <script runat="server"> Sub StoresDetailView_ItemDeleted(ByVal sender As Object, _ ByVal e As DetailsViewDeletedEventArgs) _ Handles CustomerDetailsView.ItemDeleted ' Use the Exception property to determine whether an exception ' occurred during the delete operation. If e.Exception Is Nothing Then ' Use the AffectedRows property to determine the numbers of ' rows affected by the delete operation. If e.AffectedRows = 1 Then MessageLabel.Text = e.AffectedRows.ToString() _ & " record deleted successfully." Else MessageLabel.Text = e.AffectedRows.ToString() _ & " records deleted successfully." End If Else ' Insert the code to handle the exception. MessageLabel.Text = e.Exception.Message ' Use the ExceptionHandled property to indicate that the ' exception is already handled. e.ExceptionHandled = True End If End Sub </script> <html> <body> <form runat="server"> <h3>DetailsViewDeletedEventArgs Example</h3> <asp:detailsview id="CustomerDetailsView" datasourceid="DetailsViewSource" datakeynames="CustomerID" autogeneratedeletebutton="true" autogeneraterows="true" allowpaging="true" runat="server"> <fieldheaderstyle backcolor="Navy" forecolor="White"/> </asp:detailsview> <asp:label id="MessageLabel" forecolor="Red" runat="server"/> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the web.config file. --> <asp:sqldatasource id="DetailsViewSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" deletecommand="Delete [Customers] Where [CustomerID]=@CustomerID" connectionstring= "<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
<%@ Page language="C#" %> <script runat="server"> void StoresDetailView_ItemDeleted(Object sender, DetailsViewDeletedEventArgs e) { // Use the Exception property to determine whether an exception // occurred during the delete operation. if (e.Exception == null) { // Use the AffectedRows property to determine the numbers of // rows affected by the delete operation. if (e.AffectedRows == 1) { MessageLabel.Text = e.AffectedRows.ToString() + " record deleted successfully."; } else { MessageLabel.Text = e.AffectedRows.ToString() + " records deleted successfully."; } } else { // Insert the code to handle the exception. MessageLabel.Text = e.Exception.Message; // Use the ExceptionHandled property to indicate that the // exception is already handled. e.ExceptionHandled = true; } } </script> <html> <body> <form runat="server"> <h3>DetailsViewDeletedEventArgs Example</h3> <asp:detailsview id="CustomerDetailsView" datasourceid="DetailsViewSource" datakeynames="CustomerID" autogeneratedeletebutton="true" autogeneraterows="true" allowpaging="true" onitemdeleted="StoresDetailView_ItemDeleted" runat="server"> <fieldheaderstyle backcolor="Navy" forecolor="White"/> </asp:detailsview> <asp:label id="MessageLabel" forecolor="Red" runat="server"/> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the web.config file. --> <asp:sqldatasource id="DetailsViewSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" deletecommand="Delete [Customers] Where [CustomerID]=@CustomerID" connectionstring= "<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>


System.EventArgs
System.Web.UI.WebControls.DetailsViewDeletedEventArgs


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DetailsViewDeletedEventArgs コンストラクタ
アセンブリ: System.Web (system.web.dll 内)

Dim affectedRows As Integer Dim e As Exception Dim instance As New DetailsViewDeletedEventArgs(affectedRows, e)

このコンストラクタを使用して、DetailsViewDeletedEventArgs クラスの新しいインスタンスを初期化します。
DetailsViewDeletedEventArgs のインスタンスの初期プロパティ値を次の表に示します。
AffectedRows | affectedRows パラメータの値。 |
ExceptionHandled |
![]() |
---|

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DetailsViewDeletedEventArgs プロパティ

名前 | 説明 | |
---|---|---|
![]() | AffectedRows | 削除操作の影響を受けた行の数を取得します。 |
![]() | Exception | 削除操作中に例外が発生した場合は、その例外を取得します。 |
![]() | ExceptionHandled | 削除操作中に発生した例外がイベント ハンドラで処理されたかどうかを示す値を取得または設定します。 |
![]() | Keys | 削除される項目のキー フィールドの名前と値を格納している、キー フィールドの名前/値ペアの番号付きディクショナリを取得します。 |
![]() | Values | 削除する項目のキー以外のフィールドの名前と値のペアのディクショナリを取得します。 |

DetailsViewDeletedEventArgs メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

DetailsViewDeletedEventArgs メンバ
DetailsViewDeletedEventArgs データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | AffectedRows | 削除操作の影響を受けた行の数を取得します。 |
![]() | Exception | 削除操作中に例外が発生した場合は、その例外を取得します。 |
![]() | ExceptionHandled | 削除操作中に発生した例外がイベント ハンドラで処理されたかどうかを示す値を取得または設定します。 |
![]() | Keys | 削除される項目のキー フィールドの名前と値を格納している、キー フィールドの名前/値ペアの番号付きディクショナリを取得します。 |
![]() | Values | 削除する項目のキー以外のフィールドの名前と値のペアのディクショナリを取得します。 |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

- DetailsViewDeletedEventArgsのページへのリンク