views:

543

answers:

1

Hi,

I am using ASP.NET Dynamic Data and have a custom page.

In this page I have a handle on the DetailsView inserted event where I would like to do something based on the value of the recently updated object. However, I can't put the event handling in the model class of the respective object because it is also based on the value of a custom (unbound) form element in the custom page.

How can I retrieve the object that was just updated by the DetailsView?

+1  A: 

One semi-solution that will at least give you the fields that were updated though form controls (not the new id or anything like that though) is to access the 'Values' property of the DetailsViewInsertedEventArgs like so:

protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
    if (e.Exception == null || e.ExceptionHandled)
    {
            String value = (string)e.Values["FIELDNAME"];
            Response.Redirect(table.ListActionPath);
    }
}
Graphain