c# - DBNull error using combobox with entity framework -
Application in a window using the Entity Framework, I'm struggling with Cambodia a little bit.
I is an entity device , which has 0,1 connections from any other entity <0> person . Meaning, device can contain 0 or 1 person .
To create / edit forms, I have the device , I have a Cambodia to choose Person I populate the Cumberbox like this:
personComboBox.DataSource = context.People.ToList (); PersonComboBox.DisplayMember = "name"; PersonComboBox.DataBindings.Add ("SelectedItem", toolbanking source, "person"); If I select a person , but everything is working fine, but if I leave it blank, I get the following error :
The object type 'System.DBNull' can not be changed to 'EMDataModel.Person'.
If I remove the combo box from the form, then I insert the required zeros in a new device , person field. It tells me, that the model and the database are properly configured.
What I have found is that for some reason, the blankbox returns DBNull is chosen, and the unit structure only accepts zero values, so how do I change it? ?
I'm pulling my hair for this week, and hope someone can point me in the right direction.
>
Comments
Post a Comment