Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

underlying datatable doesn't get the row from datagridview

Now, this one can be very obvious for someone, but I am stuck right on this:

Datagridview is bound to a binding source and the binding source is bound to a datatable.

Datagridview is now showing an empty row (with an asterisk).

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

When I click on a cell a cursor icon appears near that asterisk.

enter image description here

Now I am entering data in that row. When I enter a value in the first cell, a new row appears underneath this one, and the asterisk icon moves to that row. CellValueChanged gets fired, BUT in the watch window, the datatable still doesn’t have that row.

enter image description here

enter image description here

I am finishing all columns and hitting a save button, BUT still in the watch window is see that the underlying datatable is not holding that row.

enter image description here

How to get that change back to datatable? Do I need to call some method after clicking that save button? I’ve tried with _detailDataTable.AcceptChanges(); but nothing happened.

>Solution :

Call EndEdit on the BindingSource. DEFINITELY do not call AcceptChanges! That doesn’t get called until you have actually saved the changes. It will be invoked implicitly when you call Update on your adapter. If you call it first then there will be no changes to save.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading