By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,177 Members | 1,161 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,177 IT Pros & Developers. It's quick & easy.

changes in table <--> DataGrid

P: n/a

I have a DataGrid(View) and a DataTable. The DataTable is displayed in the
DataGridView. The user is allowed to select some rows and then the following
snippet updates some values in the selected rows:

foreach (DataGridViewRow row in dataGridView.SelectedRows)
row.Cells["theColumnName1"].Value = someCalculatedValue1;
row.Cells["theColumnName2"].Value = someCalculatedValue2;

Later, the changed rows in the DataTable are supposed to be recovered by
GetChanges(). But, the last selected row never is included in the rows
returned by GetChanges(). However the last selected row in the DataGridView
has visibly been changed by the mentioned foreach loop.

I think this last row is not changed in the DataTable because the changes in
a DataGridViewRow are never 'committed' in some way before changes to another
DataGridViewRow are made.

I tried a few things (like selecting other another row after the foreach
loop, hoping this would 'commit' the changes in the last selected
DataGridViewRow), but nothing helped. Anyone got a clue? It seems to me this
should be pretty straightforward...

Thanks a lot!
Nov 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.