Export (0) Print
Expand All

LinqDataSourceValidationException::InnerExceptions Property

Gets one or more exceptions that occurred when new or modified data was being validated.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

public:
virtual property IDictionary<String^, Exception^>^ InnerExceptions {
	IDictionary<String^, Exception^>^ get () sealed;
}

Property Value

Type: System.Collections.Generic::IDictionary<String, Exception>
A collection that contains the exceptions.

Implements

IDynamicValidatorException::InnerExceptions

The InnerExceptions collection contains all the validation exceptions that were thrown during data validation before an update, insert, or delete operation. A validation exception can occur if a value does not match the type of the property. For example, if you try to update an integer property by using non-numeric characters, a validation exception is thrown. A LINQ to SQL class can also contain customized validation criteria that make sure that the property contains a value that is within an expected range or pattern.

The following example shows an event handler for the Updating event. It displays any validation exception messages by using a Label control.

Protected Sub LinqDataSource_Updating(ByVal sender As Object, _
        ByVal e As LinqDataSourceUpdateEventArgs)
    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

[C#]

protected void LinqDataSource_Updating(object sender, 
        LinqDataSourceUpdateEventArgs e) 
{
    if (e.Exception != null)
    {
        foreach (KeyValuePair<string, Exception> innerException in 
            e.Exception.InnerExceptions)
        {
            Label1.Text += innerException.Key + ": " + 
                innerException.Message + "<br />";
        }
        e.ExceptionHandled = true;
    }
}

.NET Framework

Supported in: 4.5, 4, 3.5

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft