LinqDataSource.Inserted 이벤트

정의

삽입 작업이 완료되면 발생합니다.

public:
 event EventHandler<System::Web::UI::WebControls::LinqDataSourceStatusEventArgs ^> ^ Inserted;
public event EventHandler<System.Web.UI.WebControls.LinqDataSourceStatusEventArgs> Inserted;
member this.Inserted : EventHandler<System.Web.UI.WebControls.LinqDataSourceStatusEventArgs> 
Public Custom Event Inserted As EventHandler(Of LinqDataSourceStatusEventArgs) 

이벤트 유형

예제

다음 예제에서는 예외를 확인 하 고 새 레코드에 대 한 Inserted ID 속성을 검색 하는 이벤트에 대 한 이벤트 처리기를 만드는 방법을 보여 줍니다.

protected void LinqDataSource_Inserted(object sender, LinqDataSourceStatusEventArgs e)
{
    if (e.Exception == null)
    {
        Product newProduct = (Product)e.Result;
        Literal1.Text = "The new product id is " + newProduct.ProductID;
        Literal1.Visible = true;            
    }
    else
    {
        LogError(e.Exception.Message);
        Literal1.Text = "We are sorry. There was a problem saving the record. The administrator has been notified.";
        Literal1.Visible = true;
        e.ExceptionHandled = true;            
    }
}
Protected Sub LinqDataSource_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceStatusEventArgs)
    If (IsNothing(e.Exception)) Then
        Dim newProduct As Product
        newProduct = CType(e.Result, Product)
        Literal1.Text = "The new product id is " & newProduct.ProductID
        Literal1.Visible = True
    Else
        LogError(e.Exception.Message)
        Literal1.Text = "We are sorry. There was a problem saving the record. The administrator has been notified."
        Literal1.Visible = True
        e.ExceptionHandled = True
    End If
End Sub

설명

Inserted 이벤트를 처리하여 삽입 작업에서 예외를 catch하거나 삽입 작업이 완료된 후 값을 검사합니다. 이벤트 처리기에 전달되는 개체를 LinqDataSourceStatusEventArgs 통해 새 값을 검색할 수 있습니다. 예를 들어 개체를 LinqDataSourceStatusEventArgs 사용하여 새 데이터 레코드에 대해 데이터베이스에서 생성된 ID 속성을 검색할 수 있습니다.

적용 대상