Handling Updates in DataGrid

S

shumaker

I did have a save button for a datagrid that is bound to a
tableadapter, but I wanted to remove the button and instead save
updates everytime a user finishes editing a row. So I moved the update
code to the below RowLeave event. However, the problem I have is when
moving to the last new row, and then moving out, an attempt is made to
save the new row even if the user did not make any edits on it. When
using the save button before, if the user moved into the alst new row,
the default values(as defined in the tableadapter) would be populated,
but if the user then moved out of the new row without making any edits
or entering data, then the row would not be included the next time the
save button was clicked.

So I could either move the code into a different event handler, or
update the code to discard a new row if the user didn't do any data
entry on it.

In the first case, I'm not sure what a good event handler would be. I
would like to try and make updates everytime a user completes editing a
row, so that updates are made on a per row basis and any related errors
are raised immedietely.

In the second case, I have no idea how to emulate the bahavior of
discarding the last row if it is not edited.

Thanks in advance.

private void foldersToDBsJoinDataGridView_RowLeave(object sender,
DataGridViewCellEventArgs e)
{

fKProjectNamesspFoldersToDBsJoinSelectBindingSource.EndEdit();

sp_FoldersToDBsJoin_SelectTableAdapter.Update(tpocsBatchProcessConfigurationDataSet);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top