One of my business objects has a "primary" boolean property. There can be several of these objects, but only one of them can be marked as the primary entity, and there must always be one and only one primary entity.
In my datagrid, I have mapped this property to a checkbox, so that each row in the datagrid shows a text field and a checkbox. A contrived example is shown below:
Property IsPrimary
Pontiac [ ]
Ford [x]
Toyota [ ]
Nissan [ ]
There should always be one and only one primary item selected, which means that checking the box for "Ford" should have no effect, because unchecking the box would be an invalid selection and checking any other item should uncheck "Ford".
Now, in trying to separate the business logic from the user interface, what would be the best/easiest way to implement this? I have tried messing with the "IsPrimary" property on the object, to uncheck all others if a new one is checked, and it appears to work ok... it just doesn't feel "right" somehow.
Also, the business object does not appear able to prevent a checked item from becoming unchecked - yet the UI does not know this is not allowed...
Should I just implement this in the UI, or is there a better way?
Thanks!