hi,
I have an issue with databinding but i don't know if it's really LLBL or .Net who is the culprit :-)
following situation : I have an ArticleEntity which is linked m:1 to a Supplier (using the nullable foreign key SUP_ID, because an article doesn't have to be linked)
In my GUI i have a combobox with all exisiting suppliers to chose from and a "clear" button.
In my initialize code i fill the combobox using suppliercollection.getmulti(null), setting the Datasource = suppliercollection, DisplayMember = "SupName" and ValueMember = "SupId"
I also add the following databinding statement to bind it to my currentArticle
comboSuppliers.Databindings.Add("SelectedValue",currentArticle,"SupId");
When i don't select a supplier at first, the SUP_ID in the article is NULL, as it should be.
Also selecting a supplier works, and when i save my article it has the correct SUP_ID in the DB.
The problem lies in pressing the "clear" button once you allready selected a supplier.
If i use
currentArticle.SetNewFieldValue((int)ArticleFieldIndex.SupId, null);
the data is persisted correctly, but the combobox gui is not updated.
If i use
currenctArticle.SupId = 0;
the GUI is updated, but not as it should be, the first item is selected instead of no selection at all. And also persisting fails because of FK-constraint, which is normal because there is no supplier with SUP_ID = 0
I found that if i use
currenctArticle.SupId = 0;
currenctArticle.SupId = 0;
the GUI is updated correctly (no supplier selected, blank combobox). Anyone knows if this is a known issue that you have to do the statement twice ??
So i ended up with
currenctArticle.SupId = 0;
currenctArticle.SupId = 0;
currentArticle.SetNewFieldValue((int)ArticleFieldIndex.SupId, null);
this will update the GUI, and set the SupId to NULL so the article.Save works.
It looks kinda fishy code though ... is there a better way ??
oh and i DID try currentArticle.Supplier = null (no gui update), and removing and readding the bindings is no option (it is a huge form, and it would get too complex if i have to do this for multiple controls)