Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
205
New Row Not Committed to Data Source
posted

I have an UltraGrid on a Windows form.  This grid is hierarchical and is bound to a BindingSource which is bound to an EntityCollection (Entity Framework).  This hierarchy is made up of people and addresses as follows:

Person 1

-> Address 1

-> Address 2

Person 2

-> Address 1

-> Address 2

Each set of addresses has a new row template available at the bottom for adding additional addresses.  When I first enter the new row to add an address, a new address entity is created with an EntityState of Detached.  If I tab to the next row, the EntityState is changed to Added.  This is the proper behavior.

The problem is that if I use this new row to add an additional address and then click to another band instead of tabbing to the next row, the EntityState remains as detached and does not get saved to the database.  Additionally, if I click back to the original address band, the address I just added disappears.

For example:

I add an address to a person...

Doe John

-> 123 Main Street (... I press tab to move to the next line and add a second address ...)

-> 456 Central Ave (... Instead of tabbing to the next line, I click to the addresses of another person ...).

Doe Jane

-> 789 Washington Ave (... Here.)

... If I then click back to the addresses for John Doe, the 456 Central Ave address disappears because I never tabbed off of that line.

How do I prevent this behavior.

Parents Reply Children