|
Parent = context.table
child = From t in parent where ...
In properties, the datasource is set to parent as well.
The bindingnavigators.bindingsource are set to child, all controls and datagrids are bound to the child bindingsoure.
Add new will instaniate a new row. It displays in the datagrids; however, it will not save. The primary key field maintains 0. As soon as I sort or call a new query the row is gone. On reload the row is gone.
Is there a problem with a child binding source?
me.validate()
me.parentsource.endedit()
me.child.endedit()
parent.resetcurrentitem()
me.context.submitchanges()
I have tried ending edit in reverse order and not reseting the current item (needed to update the changes, which works correctly for some strange crazy reason). The problem exists solely with saving a new row.
Does it make a difference that there are two binding navigators? Due to space and design, I opted for 2, but I have tried the addnew on the second.
Hmmm ... Ideas? (Asked in VB too. Saw the forms forum after.)
|
|
|
|
|
Actually, I solved this in quite an odd manner. I added a textbox for the primary key that was linked (bound) to the parent datasource. This solved the add new.
Why the child could not aquire a key value is beyond me. I simply hid the textbox by placing it behind another control. Oh, that reminds me. You cannot set the visibility to false and the key still add. Again, another thing that eludes me entirely. What does visibility have to do with it? I could not find any documentation that linked the visible status to the enabled status, but ah well. Problem was solved.
|
|
|
|