Using V2.0.0.0, self servicing scenario, and vs2005.
Situation:
- Database table with a not nullable foreign key field.
- The related entity's fields holding the foreign key values are also not nullable (logical)
- I bind a collection of those entities to a datagrid
- The datagrid's column, which shows the foreign key, is a DataGridViewComboBox, filled with all possible values.
- The grid's property 'AllowUserToAddRows' is set to 'true'
- Now, try to click into the last (new) line in the grid during run time
The following messagebox occurs:
The following exception occurred in the DataGridView:
System.ArgumentException: DataGridViewComboBoxCell value is not valid.
To replace this default dialog please handle the DataError event.
This is, as i found out, because the DataSource of the Grid, which ist a EntityCollection, doesn't allow null values in the fk-field, and the grid tries to do that when entering the last row. I tried to prevent the grid from doing this, but didn't succeed.
Is the only possible solution to add the new line by code an set the 'AllowUserToAddRows' property to false? Does anybody have an suggestion, how to do this in the way i tried as described above?
Thanks in advance!