DetailsViewInsertedEventArgs.ExceptionHandled プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As DetailsViewInsertedEventArgs Dim value As Boolean value = instance.ExceptionHandled instance.ExceptionHandled = value
/** @property */ public boolean get_ExceptionHandled () /** @property */ public void set_ExceptionHandled (boolean value)
public function get ExceptionHandled () : boolean public function set ExceptionHandled (value : boolean)
イベント ハンドラで例外が処理された場合は true。それ以外の場合は false。既定値は false です。

挿入操作中に例外が発生すると、ExceptionHandled プロパティを使用して、イベント ハンドラで例外が処理されたかどうかを示します。このプロパティが true に設定されている場合、例外は処理されたと見なされ、呼び出し履歴に渡されません。このプロパティが false に設定されている場合、例外は呼び出し履歴の次のメソッドに渡され、処理が行われます。例外が発生したかどうかを確認するには、Exception プロパティを使用します。

ExceptionHandled プロパティを使用して、例外がイベント ハンドラで処理されたことを示す方法のコード例を次に示します。
<%@ Page language="VB" autoeventwireup="false" %> <script runat="server"> Sub CustomerDetailsView_ItemInserted(ByVal sender As Object, _ ByVal e As DetailsViewInsertedEventArgs) _ Handles CustomerDetailsView.ItemInserted ' Use the Exception property to determine whether an exception ' occurred during the insert operation. If e.Exception Is Nothing And e.AffectedRows = 1 Then ' Use the Values property to get the value entered by ' the user for the CompanyName field. Dim name As String = e.Values("CompanyName").ToString() ' Display a confirmation message. MessageLabel.Text = name & " added 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 ' When an exception occurs, keep the DetailsView ' control in insert mode. e.KeepInInsertMode = True End If End Sub </script> <html> <body> <form runat="server"> <h3>DetailsViewInsertedEventArgs Example</h3> <asp:detailsview id="CustomerDetailsView" datasourceid="DetailsViewSource" datakeynames="CustomerID" autogenerateinsertbutton="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]" insertcommand="INSERT INTO [Customers]([CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country]) VALUES (@CustomerID, @CompanyName, @Address, @City, @PostalCode, @Country)" connectionstring= "<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
<%@ Page language="C#" %> <script runat="server"> void CustomerDetailsView_ItemInserted(Object sender, DetailsViewInsertedEventArgs e) { // Use the Exception property to determine whether an exception // occurred during the insert operation. if (e.Exception == null && e.AffectedRows == 1) { // Use the Values property to get the value entered by // the user for the CompanyName field. String name = e.Values["CompanyName"].ToString(); // Display a confirmation message. MessageLabel.Text = name + " added 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; // When an exception occurs, keep the DetailsView // control in insert mode. e.KeepInInsertMode = true; } } </script> <html> <body> <form runat="server"> <h3>DetailsViewInsertedEventArgs Example</h3> <asp:detailsview id="CustomerDetailsView" datasourceid="DetailsViewSource" datakeynames="CustomerID" autogenerateinsertbutton="true" autogeneraterows="true" allowpaging="true" oniteminserted="CustomerDetailsView_ItemInserted" 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]" insertcommand="INSERT INTO [Customers]([CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country]) VALUES (@CustomerID, @CompanyName, @Address, @City, @PostalCode, @Country)" connectionstring= "<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>

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に収録されているすべての辞書からDetailsViewInsertedEventArgs.ExceptionHandled プロパティを検索する場合は、下記のリンクをクリックしてください。

- DetailsViewInsertedEventArgs.ExceptionHandled プロパティのページへのリンク