problem detecting changes on parent-child bindingsources

slluch

Member
Joined
Apr 19, 2008
Messages
6
Programming Experience
5-10
Hi!. I have a problem with bindingsource endEdit method. I have a bindingsource binded to a table from a dataset. I have another bindingsource binded to a relation from the first bindingsource (parent-child relation). I have a form with several textboxes binded to the first bindingsource (parent) and some textboxes binded to the second bindingsource (child). My problem is that when i call EndEdit method on the first bindingsource, the underlying dataset detect changes but if I call EndEdit method on the second...the dataset.HasChanges method returns false.



Code :

'parent bindingource

Me.BindingSource1.DataSource = dsDetalleArticulo

Me.BindingSource1.DataMember = "TARTICULOS"

'child bindingsource

bsArticulosClientes.DataSource = Me.BindingSource1

bsArticulosClientes.DataMember = "ArticulosClientes"


Code to check for changes:

bsArticulosClientes.EndEdit()

Me.BindingSource1.EndEdit()

'the following line only returns true when the changes affect textboxes binded to the parent bindingsource

If dsDetalleArticulo.HasChanges Then

......

end if





Any ideas?



Thank you
 
Mmmm. Related bindingsources causing more problems I see

I found when I was working with them that if I AddNew to the parent, then AddNew to the child, then edited the data in both, as soon as I called EndEdit on the parent, it destroyed all the data in the child. If I called it on the child first, the relation failed because the parent record wasnt in the datatable. It's very annoying

My workaround is to call EndEdit on the parent immediately after I call AddNew, then call the chld AddNew /EndEdit
Then I can edit them successfully

In case this issue also affects your situation, you can try the workaround I follow?
 
Hi. thanks for your answer. The problem was that i called endedit on the PositionChanged event of the underlying bindingsource. I change to currentchanged event and works fine.

Thank you
 

Latest posts

Back
Top