StrataFrame Forum

Allow null value in business object

http://forum.strataframe.net/Topic1829.aspx

By Wang Tong Yin - 7/13/2006

Some of the fields in my table allow null value. Especially for datetime and decimal field. I want the default value of the controls, which mapped to these fields is null string ("") during initialization of add new record screen. How can I customize the fields in business object mapper so that the default value can be null string?
By StrataFrame Team - 7/13/2006

When a new record it added, the business object automatically initializes the values within the new row to remove any DBNull.Value values.  To prevent this, and allow all of the fields within the new row to be NULL, set the AllowNullValuesOnNewRow property on the business object to True.

If you only want a few fields to have NULL values, then in the SetDefaultValues event handler, add this code:

Me.CurrentRow("fieldname") = DBNull.Value

Add that for each field you want to initialize as a null value, and you'll be good to go.