Published on

Getting the ID of a newly inserted record

Authors
  • avatar
    Name
    Mike Barram
    Twitter

if you’re using a <data:MultiFormView ID="FormView1"> bound to a <data:MyTableDataSource> then it isn’t obvious how to get the ID of a record that you’ve just inserted e.g. you might want to redirect back to the same form but with the new ID in the querystring to further edit the form or related information.

This is all you need to do:

protected void FormView1_ItemInserted(Object sender, EventArgs e)  
{  
    int Myid = BMyTableDataSource.EntityId.Myid;  
}