I'm obviously missing something pretty basic here but I can't see it. I have a table with a GUID as a PK. When I save a new record I get the error:
BusinessLayerException An error occurred while saving an the data to the server.DataLayerSavingException Cannot insert the value NULL into column 'AGTID', table 'TMS201.dbo.tblAGTAttrGroupTypes'; column does not allow nulls. INSERT fails.The statement has been terminated.SqlException Cannot insert the value NULL into column 'AGTID', table 'TMS201.dbo.tblAGTAttrGroupTypes'; column does not allow nulls. INSERT fails.
However, in the BO I have the field set as per screen shot - note the screen shot also shows the property code for the column. I have tried setting the bo control value to "Return Alternate on Null" but the result is the same.
I also noticed that, when I create a new row, a checkbox for which I have a default value of 'True', is unticked on the new record. I was presuming that the defaults settings in the BO would take effect when a new is presented to the user for initial data entry - is this not so?
BTW my test form is using a DevEx grid.
Cheers, Peter
Thanks for the comment. I wonder then, if the developer has to hand code defaults what purpose does the "null value option" serve - maybe I've misunderstood how that is used within SF.
As for the "Null value options" they are in place because ADO.NET represents null database values with DBNull.Value, and the DBNull type cannot be converted to any other data type (save object), and so when you access the get of a field property that has a null, you will get an InvalidCastException. So, if you want your database to allow null values, then you will need to configure the fields that you want to allow null values to return some other value when a DBNull.Value is encountered.