Hello everybody,
i have a dataset with 2 datatables(master detail), a binding source(bs1) that has as datasource the dataset and as datamember the first table which is the master table. On the user control i use 3 datetime editors which has the property values set to the "bs1 - columnname". Also i have another bindingsource(bs2) which has as datasource the dataset but as datamember the detail table. The bs2 is used as the datasource of an ultragrid.
Everything is working but there is a problem, really strange one!
Now, i use this usercontrol on a form, and if i enter in edit mode in a particular column of the grid and then try to close the form i get ""Cannot bind to the property or column DATA on the datasource"".
What probably happens is that the BindingContext of the form is destroyed by the time the datetime control attempts to bind to it. Since there is no binding context, then the binding fails.
Any idea?
Thank you.
Hi,
I'm finding it really hard to follow exactly what's going on here just from your description. Is the grid inside the usercontrol on is it on the form separately as a sibling to the usercontrol?
When does the error occur? Why would the BindingContext be destroyed when you simply enter a value?
Perhaps you could post a small sample project demonstrating the error.
Hi Mike,
i cant reproduce this on a separate project. I'll try to explain better.
This is the form:
The red rectangle is the user control tha contains all the stuff at the same level. There is no other user control within this usercontrol, only infragistics components. The user control has only some public method which are called by the buttons on the ribbon. On the form there is no other logic.
The green rectangle is the master part. All the controls in this part are binded to the bs1 which has as datasource the dataset used by this uc and as datamemeber the master table.
The yellow rectangle is the detail part. The grid is inside a ultratabcontrol and has as datasource bs2.
bs2 has as datasource the same dataset used previously and as datamember a table that is a detail table.
Now where is the problem? The problem is that if i open this form, enter in edit mode on the cell indicated by the red arrow, and then close the form i get the error:
""Cannot bind to the property or column DATA on the datasource. Parameter name: dataMember"".
The control indicated by the blue arrow has the value = "bs1 - DATA" so this is the component that it is generating the error. In fact if i remove the binding i have no error!
if i'm on another cell of the grid and close the form i have no errors!!
You have wrote "When does the error occur? Why would the BindingContext be destroyed when you simply enter a value? ". I dont know Mike :) it was simply what i was thinking... :) I dont know if it is correct.
If the grid and the other controls on the form are bound to two different tables, then I can't see why this would cause a problem of any kind.
Is the error an exception? Is there a call stack? Or is it just a MessageBox? If there's a call stack, please post it here and maybe that will give us some clue about what's causing this.
If it's just a MessageBox, then try trapping the grid's CellDataError and Error events and see if one or the other is firing. If so, there will be a call stack showing how the event was triggered and that might help.
Another thing you might want to try, just to see if this is even related to the grid at all, is to try using the DataGridView in place of the UltraWinGrid and see if the error still happens. My guess is that this error is not specific to the grid, but is rather some weird binding issue.
The problem is that i'm not able to reproduce this on a new solution.
If it can help, i have the same problem on another form but this time is not an ultradatetimeditori instead it is an ultratexteditor.
Here is the stack http://www.evald.eu/public/longstackUltraTextEditor.txt
It's very tough to tell and there's a lot going on here.
It looks like maybe the DataSource is getting disposed first, and then the UserControl, and at this point the form is trying to set focus to the DateTimeEditor, which then tries to access the DataSource, which is no longer there. Or something sort've along those lines.
This could be a bug in the DateTimeEditor, because it looks like it's trying to determine if it is HotTracking while this is going on. But there's really not much we can do to fix this without being able to duplicate it. If you can whip up a small sample project that demonstrates this, we would be more than happy to check it out.
In the mean time, it sounds like your solution is a good one.
a little update:
for now i have solved, clearing the databinding on the dispose method. ultraDateTimeEditorPartitaData.DataBindings.Clear();
yes, the grid and the other controls on the form are bound to two different tables and that is why i think this is a strange error.
It throws an argumentexception and here it is the stack!
and here you can find the complete stack trace with the [External code] http://www.evald.eu/public/longstack.txt
I believe its a problem with UltraDateTimeEditor because this strange problem occurs also on another application that is using the UltraDateTimeEdito.
ps:Mike, thank you for your time!