LinqDataSourceInsertEventArgs.Exception プロパティ
定義
挿入操作の前に行われていたデータ検証中にスローされた例外を取得します。Gets the exception that was thrown while the data was being validated before the insert operation.
public:
property System::Web::UI::WebControls::LinqDataSourceValidationException ^ Exception { System::Web::UI::WebControls::LinqDataSourceValidationException ^ get(); };
public System.Web.UI.WebControls.LinqDataSourceValidationException Exception { get; }
member this.Exception : System.Web.UI.WebControls.LinqDataSourceValidationException
Public ReadOnly Property Exception As LinqDataSourceValidationException
プロパティ値
エラーが発生した場合は例外。それ以外の場合は null
。The exception, if an error occurred; otherwise, null
.
例
次の例は、イベントのハンドラーを示して Inserting います。The following example shows a handler for the Inserting event. コントロールを使用して、検証例外メッセージを表示し Label ます。It displays any validation exception messages by using a Label control.
Protected Sub LinqDataSource_Inserting(ByVal sender As Object, _
ByVal e As LinqDataSourceInsertEventArgs)
If (e.Exception IsNot Nothing) Then
For Each innerException As KeyValuePair(Of String, Exception) _
In e.Exception.InnerExceptions
Label1.Text &= innerException.Key & ": " & _
innerException.Value.Message + "<br />"
Next
e.ExceptionHandled = True
End If
End Sub
protected void LinqDataSource_Inserting(object sender,
LinqDataSourceInsertEventArgs e)
{
if (e.Exception != null)
{
foreach (KeyValuePair<string, Exception> innerException in
e.Exception.InnerExceptions)
{
Label1.Text += innerException.Key + ": " +
innerException.Value.Message + "<br />";
}
e.ExceptionHandled = true;
}
}
注釈
挿入操作が実行される前に検証例外がスローされた場合、例外はプロパティに格納され Exception ます。If a validation exception is thrown before the insert operation is performed, the exception is stored in the Exception property. イベントのハンドラーでは、 Inserting プロパティを使用して例外を取得でき Exception ます。In a handler for the Inserting event, you can retrieve the exception through the Exception property.