views:

253

answers:

2

Hello,

I was under the impression that upon binding a dataGridView object to a dataTable that any changes the user makes in the dataGridView are then recorded in the dataTable. These changes include switches in column order, sorting, and the addition and deletion of rows. However, this does not seem to be the case. I am finding that changing column order, sorting, and occasionally the addition of rows is not reflected in the underlying dataTable. Are these changes that need to be made programmatically instead?

Thanks!

+1  A: 

Yes, sorting and reordering columns are just different visual representations of the same data. This does NOT affect the underlying DataTable. Adding and deleteing rows should always work unless if there's some conflict like a primary key or something like that. Also, adding rows is only reflected in the DataTable after the user clicks out of the row in the DataGridView. The edit isn't committed up until that point.

BFree
A: 

Thank you! Your adding rows comment clears up the situation greatly! Do you know if there is any way to have the change immediately reflected in the datatable when the row is first created in the datagridview?