How do I set a default value?


Author
Message
Peter Jones
Peter Jones
Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi,

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

Replies
Peter Jones
Peter Jones
Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Ben,

Thanks, I had seen that property and read about it but it slipped my mind. Can you please respond to the second question in my previous post.

Cheers, Peter

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Ah, as for the second question, the business object does not test the values for NULLs when saving... it just saves whatever is within the DataTable.  The configuration within the BOMapper specifies how the strong-typed property for the field is created.  So, if you use the Return Alternat on Null, then when the DataTable contains a NULL value for the field, the property will return an alternate value.  As for the Set Null on Alternate, when you try to set the alternate value back to the field, the property sets the field to a NULL value rather than the value that you passed.

So, the BOMapper settings only affect the getting and setting of properties.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search