Click here to Skip to main content
15,922,894 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
How to write a linqdatasource _inserting (object sender,linqDatasourceInsertEvent args)?

I use a detail view (select from masterview already), but when i write back to sql i will take either a session[userid] or master gridview1.[userId] selected value.

Or just simply ask for Inserting function for Linqdatasoure with LinquDataSourceInsertEvent?
Posted
Updated 14-Mar-11 14:04pm
v2

1 solution

I found that on msdn, maybe help ?

C#
protected void LinqDataSource_Inserting(object sender, LinqDataSourceInsertEventArgs e)
{
    Product product = (Product)e.NewObject;
    product.DateModified = DateTime.Now;
}



XML
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;
    }
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900