LinqDataSourceInsertEventArgs.Exception Özellik

Tanım

Ekleme işleminden önce veriler doğrulanırken oluşan özel durumu alır.

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

Özellik Değeri

Hata oluştuysa özel durum; aksi takdirde , null.

Örnekler

Aşağıdaki örnekte olay için bir işleyici gösterilmektedir Inserting . Denetim kullanarak Label tüm doğrulama özel durum iletilerini görüntüler.

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

Açıklamalar

Ekleme işlemi gerçekleştirilmeden önce bir doğrulama özel durumu oluşturulursa, özel durum özelliğinde Exception depolanır. Olay işleyicisinde Inserting , özelliği aracılığıyla Exception özel durumu alabilirsiniz.

Şunlara uygulanır