LinqDataSourceValidationException.InnerExceptions Property

Definition

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

C#
public System.Collections.Generic.IDictionary<string,Exception> InnerExceptions { get; }

Property Value

A collection that contains the exceptions.

Implements

Examples

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

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;  
    }  
}  

Remarks

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.

Applies to

Produkt Verzie
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1