Binding a DataGridView column to a nullable property, using a ComboBox bound to a non-nullable property.
Windows Forms
1
Posts
1
Posters
2
Views
1
Watching
-
I have two objects, PriceRule and WeekDay, and PriceRule has a DayId column I have bound to a ComboBox column in a DataGridView. When I load the grid, if DayId is null, the combo is blank, but as soon as I drop the combo down, I have to select a day. No problem, I can inject an extra empty string day into the combo's data source, but the Id property of WeekDay is not nullable, so I need to do something as clumsy and stupid as insert a false day with Id of -1. How do I catch this -1 and make it null before saving, and vice versa, catch a null DayId and make it -1 when loading? Is there no other way to do what is a bloody common task that MS clearly isn't capable of handling themselves?