Implementing IDProperty

Implementing IDProperty

Old forum URL:

Smitty157 posted on Sunday, October 23, 2011

How should basic IDProperties be implemented in BusinessBase objects?

I have a BusinessBase object that requires the selection of a value from a combo box control populated with a list of items from a NameValueListBase object.  The property on the BusinessBase object is defined as a Long.  This means that this value defaults to a 0 and thus always has a value.  While using data binding, if a user selects an option from the combo box and then clears the combo box the binding source object is trying to set my Long property to NULL, which causes a NULL to Long conversion exception.

Should the IdProperty be implemented as a Long type, or should a different type be used that accepts the use of a NULL value?  At times, Id properties should allow the use of NULL values.  What type should be used to allow the user to insert NULL Id values into a database?  Also, since a long type always has a value (default of 0) the common Required rule never works.  It seems like the Long data type is not the correct type to use.


Copyright (c) Marimer LLC