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


GridView コントロールは、コントロール内の Delete ボタン (CommandName プロパティが "Delete" に設定されたボタン) がクリックされた場合に、GridView コントロールが実際にレコードを削除した後に RowDeleted イベントを発生させます。これにより、このイベントが発生するたびにカスタム ルーチン (削除操作の結果を確認するなど) を実行するイベント処理メソッドを提供できます。
GridViewDeletedEventArgs オブジェクトがイベント処理メソッドに渡されることにより、影響を受けたレコード数および発生した例外を確認できます。削除操作の影響を受けたレコード数を確認するには、AffectedRows プロパティを使用します。例外が発生しているかどうかを確認するには、Exception プロパティを使用します。ExceptionHandled プロパティを設定することにより、イベント処理メソッドで既に例外が処理されたかどうかを示すこともできます。
![]() |
---|
削除操作中に例外が発生し、ExceptionHandled プロパティが false に設定されている場合は、GridView コントロールによって例外が再度スローされます。 |
削除されたレコードのキー フィールドおよびキー以外のフィールドの名前と値のペアにアクセスする場合は、Keys プロパティ (名前の場合) と Values プロパティ (値の場合) を使用します。

RowDeleted イベントのイベント処理メソッドに渡された GridViewDeletedEventArgs オブジェクトを使用して、削除操作中に例外が発生したかどうかを確認する方法を次の例に示します。
<%@ Page language="VB" %> <script runat="server"> Sub CustomersGridView_RowDeleted(ByVal sender As Object, ByVal e As GridViewDeletedEventArgs) ' 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 whether the ' record was deleted. Sometimes an error might occur that ' does not raise an exception, but prevents the delete ' operation from completing. If e.AffectedRows = 1 Then Message.Text = "Record deleted successfully." Else Message.Text = "An error occurred during the delete operation." End If Else ' Insert the code to handle the exception. Message.Text = "An error occurred during the delete operation." ' 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>GridViewDeletedEventArgs Example</h3> <asp:label id="Message" forecolor="Red" runat="server"/> <br/> <!-- The GridView control automatically sets the columns --> <!-- specified in the datakeynames property as read-only. --> <!-- No input controls are rendered for these columns in --> <!-- edit mode. --> <asp:gridview id="CustomersGridView" datasourceid="CustomersSqlDataSource" autogeneratecolumns="true" autogeneratedeletebutton="true" datakeynames="CustomerID" onrowdeleted="CustomersGridView_RowDeleted" runat="server"> </asp:gridview> <!-- 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="CustomersSqlDataSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" deletecommand="Delete from Customers where CustomerID = @CustomerID" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"> </asp:sqldatasource> </form> </body> </html>
<%@ Page language="C#" %> <script runat="server"> void CustomersGridView_RowDeleted(Object sender, GridViewDeletedEventArgs 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 whether the // record was deleted. Sometimes an error might occur that // does not raise an exception, but prevents the delete // operation from completing. if (e.AffectedRows == 1) { Message.Text = "Record deleted successfully."; } else { Message.Text = "An error occurred during the delete operation."; } } else { // Insert the code to handle the exception. Message.Text = "An error occurred during the delete operation."; // Use the ExceptionHandled property to indicate that the // exception is already handled. e.ExceptionHandled = true; } } </script> <html> <body> <form runat="server"> <h3>GridViewDeletedEventArgs Example</h3> <asp:label id="Message" forecolor="Red" runat="server"/> <br/> <!-- The GridView control automatically sets the columns --> <!-- specified in the datakeynames property as read-only. --> <!-- No input controls are rendered for these columns in --> <!-- edit mode. --> <asp:gridview id="CustomersGridView" datasourceid="CustomersSqlDataSource" autogeneratecolumns="true" autogeneratedeletebutton="true" datakeynames="CustomerID" onrowdeleted="CustomersGridView_RowDeleted" runat="server"> </asp:gridview> <!-- 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="CustomersSqlDataSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" deletecommand="Delete from Customers where CustomerID = @CustomerID" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"> </asp:sqldatasource> </form> </body> </html>


System.EventArgs
System.Web.UI.WebControls.GridViewDeletedEventArgs


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


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

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

このコンストラクタを使用して、GridViewDeletedEventArgs クラスの新しいインスタンスを初期化します。
GridViewDeletedEventArgs のインスタンスの初期プロパティ値を次の表に示します。
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


GridViewDeletedEventArgs プロパティ

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

GridViewDeletedEventArgs メソッド

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

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

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


名前 | 説明 | |
---|---|---|
![]() | 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 から継承されます。) |

- GridViewDeletedEventArgsのページへのリンク