I have a Windows form bound to a DataTable through a BindingSource. When I call EndEdit on this BindingSource, it does not always change DataTable to show the modifications, and calling GetChanges on the DataSet returns null.
Here's the situation in more detail - I have a DataSet, and a BindingSource bound to that dataset. There is then a BindingSource bound to the Regulators table in the DataSet. It looks something like this (summary) :
m_bs = new BindingSource(dataSet); m_regulatorsBs = new BindingSource(m_bs, "Regulators");
I have a list of choices in a DataGridView, bound to this second BindingSource:
mainView.DataSource = m_regulatorsBs;
I then have a details control, with many controls bound to the same BindingSource. When a user clicks on an item in the DataGridView, the position of the BindingSource changes and the new record's details are shown on the details control. So far so good.
But before saving data, I want to make sure that any edits are committed to the DataTable again. To do this I call:
Now here's the wierd thing. This works only when I'm viewing the first record. Doing this with subsequent records seems to have no effect. The DataTable does not show any modifications. Oddly, if I get the DataRowView that the BindingSource is pointing to, and call EndEdit on this, it works:
DataRowView drv = (DataRowView)m_regulatorsBs.Current; drv.EndEdit();
But I'd rather not make any assumptions about what the BindingSource is pointing to, and EndEdit is supposed to do this anyway, as far as I understand.
Does anyone know why this might be working only for the first record? Is it a known bug?