If you are using an Array, (I recomend that you do), to hold the data when you populate the datagrid, you can just simply check if the values are the same.
You can simply do something like this:
if (newDatagridValue != OldDatagridValue)
{
databaseField = newDatagridValue;
}
(this is ofcourse pseudocode to show you what I mean, and not usable)
So if the Array holding the information you have presented is compared to a new array, that is made when you hit the "exit" button, you can see if it has changed and rewrite your data-source to reflect your changes.
-Frank