Adding New Row

Hi,
I’m having problems updating data for a newly added grid row.
I add a new row to my grid using

 mygrid.addRow((new Date()).valueOf(),[0,'','','','','','',''],0);

the blank row is added into the grid at the top.

I then use the following code to insert a new record into my database, return new record Id, and update the Id in the grid for the new blank row.

public void Insert(ref XmlElement root, NameValueCollection data) { // Loop through collection getting data for (int i = 0; i < data.Count; i++) { if (data.GetKey(i).ToString() == "gr_id") { thisGridIndex = data.Get(i).ToString(); } } // Insert data into database returning new record Id if(InsertNewRecordintoDB(ref newRecordId) == 1) { ResponseXMLAction(ref root, "insert", thisGridIndex, newRecordId); } }
However when I try to edit and update the new blank row, the grid displays the new data, but it is not saved to the database (using a similar routine to the one above, but for updates).

The correct new Id is being returned from the database, and other rows are updated fine, its just the newly added row which doesnt update.

Does anyone know where I could be going wrong?