ObjectDataSourceStatusEventArgs.ExceptionHandled プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ObjectDataSourceStatusEventArgs.ExceptionHandled プロパティの意味・解説 

ObjectDataSourceStatusEventArgs.ExceptionHandled プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

ビジネス オブジェクトによりスローされた例外処理されたかどうか示す値を取得または設定します

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Property ExceptionHandled As
 Boolean
Dim instance As ObjectDataSourceStatusEventArgs
Dim value As Boolean

value = instance.ExceptionHandled

instance.ExceptionHandled = value
public bool ExceptionHandled { get;
 set; }
public:
property bool ExceptionHandled {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_ExceptionHandled ()

/** @property */
public void set_ExceptionHandled (boolean value)
public function get ExceptionHandled
 () : boolean

public function set ExceptionHandled
 (value : boolean)

プロパティ
ビジネス オブジェクトによりスローされた例外処理され、ObjectDataSource がその例外スローする必要がない場合true返されます。それ以外場合false返されます。

解説解説
使用例使用例

ビジネス オブジェクトおよび GridView コントロールで、ObjectDataSource コントロール使用してデータ削除する方法次のコード例示しますGridView は、SelectMethod プロパティによって指定されメソッドEmployeeLogic オブジェクトからデータ取得し最初に従業員表示します。AutoGenerateDeleteButton プロパティtrue設定されているため、GridView コントロール自動的に削除ボタン表示します

削除ボタンクリックすると、DeleteMethod プロパティ指定されメソッド、および DeleteParameters コレクション指定されパラメータ使用して Delete 操作実行されます。このコード例では、プリプロセスとポスト プロセスステップ一部実行されます。NorthwindEmployeeDeleting デリゲートは、Delete 操作実行前に Deleting イベント処理するために呼び出されます。また、NorthwindEmployeeDeleted デリゲートは、Delete 操作完了後に Deleted イベント処理するために呼び出されます。これにより発生した例外処理されます。この例では、NorthwindDataExceptionスローされた場合NorthwindEmployeeDeleted デリゲートによって処理されます。

このコード例使用されている EmployeeLogic 中間層ビジネス オブジェクト実装調べるには、 ObjectDataSourceStatusEventArgs クラス概要参照してください

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB"
 Assembly="Samples.AspNet.VB"
 %>
<%@ Import namespace="Samples.AspNet.VB"
 %>
<%@ Page language="vb" %>
<Script runat="server">
' Called before a Delete operation.
    Private Sub NorthwindEmployeeDeleting(ByVal
 source As Object, ByVal
 e As ObjectDataSourceMethodEventArgs)

        ' The GridView passes the ID of the employee
        ' to be deleted. However, the business object, EmployeeLogic
,
        ' requires a NorthwindEmployee parameter, named "ne".
 Create
        ' it now and add it to the parameters collection.
        Dim paramsFromPage As IDictionary =
 e.InputParameters
  
        If Not paramsFromPage("EmpID")
 Is Nothing Then
    
            Dim ne As New
 NorthwindEmployee(paramsFromPage("EmpID").ToString())
            ' Remove the old EmpID parameter.
            paramsFromPage.Clear()
            paramsFromPage.Add("ne", ne)
    
    
        End If
    End Sub ' NorthwindEmployeeDeleting

    ' Called after a Delete operation.
    Private Sub NorthwindEmployeeDeleted(ByVal
 source As Object, ByVal
 e As ObjectDataSourceStatusEventArgs)
        ' Handle the Exception if it is a NorthwindDataException.
        If Not e.Exception Is
 Nothing Then

            ' Handle the specific exception type. The ObjectDataSource
 wraps
            ' any Exceptions in a TargetInvokationException wrapper,
 so
            ' check the InnerException property for the expected Exception
 types.
            If e.Exception.InnerException.GetType().Equals(GetType(NorthwindDataException))
 Then

                Label1.Text = e.Exception.InnerException.Message
                ' Because the exception is handled, there is
                ' no reason to throw it.
                e.ExceptionHandled = True
      
            End If
        End If
    End Sub ' NorthwindEmployeeDeleted
</Script>
<html>
  <head>
    <title>ObjectDataSource - VB Example</title>
  </head>
  <body>
    <form id="Form1" method="post"
 runat="server">

        <asp:gridview
          id="GridView1"
          runat="server"
          datasourceid="ObjectDataSource1"
          autogeneratedeletebutton="true"
          autogeneratecolumns="false"
          datakeynames="EmpID">
          <columns>
            <asp:boundfield headertext="EmpID"
 datafield="EmpID" />
            <asp:boundfield headertext="First Name"
 datafield="FirstName" />
            <asp:boundfield headertext="Last Name"
 datafield="LastName" />
          </columns>
        </asp:gridview>

        <asp:objectdatasource
          id="ObjectDataSource1"
          runat="server"
          selectmethod="GetAllEmployees"
          deletemethod="DeleteEmployee"
          ondeleting="NorthwindEmployeeDeleting"
          ondeleted="NorthwindEmployeeDeleted"
          typename="Samples.AspNet.VB.EmployeeLogic">
          <deleteparameters>
            <asp:parameter name="EmpID" type="Int32"
 />
          </deleteparameters>
        </asp:objectdatasource>

        <asp:label id="Label1" runat="server"
 />

    </form>
  </body>
</html>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS"
 Assembly="Samples.AspNet.CS" %>
<%@ Import namespace="Samples.AspNet.CS" %>
<%@ Page language="c#" %>
<Script runat="server">
private void NorthwindEmployeeDeleting(object
 source, ObjectDataSourceMethodEventArgs e)
{
  // The GridView passes the ID of the employee
  // to be deleted. However, the buisiness object, EmployeeLogic,
  // requires a NorthwindEmployee parameter, named "ne". Create
  // it now and add it to the parameters collection.
  IDictionary paramsFromPage = e.InputParameters;
  if (paramsFromPage["EmpID"] != null)
 {
    NorthwindEmployee ne
      = new NorthwindEmployee( Int32.Parse(paramsFromPage["EmpID"].ToString()));
    // Remove the old EmpID parameter.
    paramsFromPage.Clear();
    paramsFromPage.Add("ne", ne);
  }
}

private void NorthwindEmployeeDeleted(object
 source, ObjectDataSourceStatusEventArgs e)
{
  // Handle the Exception if it is a NorthwindDataException
  if (e.Exception != null)
  {

    // Handle the specific exception type. The ObjectDataSource wraps
    // any Exceptions in a TargetInvokationException wrapper, so
    // check the InnerException property for expected Exception types.
    if (e.Exception.InnerException is NorthwindDataException)
    {
      Label1.Text = e.Exception.InnerException.Message;
      // Because the exception is handled, there is
      // no reason to throw it.
      e.ExceptionHandled = true;
    }
  }
}

</Script>
<html>
  <head>
    <title>ObjectDataSource - C# Example</title>
  </head>
  <body>
    <form id="Form1" method="post" runat="server">

        <asp:gridview
          id="GridView1"
          runat="server"
          datasourceid="ObjectDataSource1"
          autogeneratedeletebutton="true"
          autogeneratecolumns="false"
          datakeynames="EmpID">
          <columns>
            <asp:boundfield headertext="EmpID" datafield="EmpID"
 />
            <asp:boundfield headertext="First Name" datafield="FirstName"
 />
            <asp:boundfield headertext="Last Name" datafield="LastName"
 />
          </columns>
        </asp:gridview>

        <asp:objectdatasource
          id="ObjectDataSource1"
          runat="server"
          selectmethod="GetAllEmployees"
          deletemethod="DeleteEmployee"
          ondeleting="NorthwindEmployeeDeleting"
          ondeleted="NorthwindEmployeeDeleted"
          typename="Samples.AspNet.CS.EmployeeLogic">
          <deleteparameters>
            <asp:parameter name="EmpID" type="Int32" />
          </deleteparameters>
        </asp:objectdatasource>

        <asp:label id="Label1" runat="server" />

    </form>
  </body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ObjectDataSourceStatusEventArgs クラス
ObjectDataSourceStatusEventArgs メンバ
System.Web.UI.WebControls 名前空間
ObjectDataSourceStatusEventArgs.Exception プロパティ



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

ObjectDataSourceStatusEventArgs.ExceptionHandled プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ObjectDataSourceStatusEventArgs.ExceptionHandled プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS