It seems like Txt_reference_date.Text is not recognized as a valid DateTime. Conditional operator is not the issue here.
You can try :
DateTime d;
obenitiypersonal.reference_date =
(DateTime.TryParse(Txt_reference_date.Text, out d))
? d
: DateTime.MinValue;
Here I assume that
obenitiypersonal.reference_date
is a DateTime struct.
If
obenitiypersonal.reference_date
were a
DateTime?
(
Nullable<datetime></datetime>
), you could write :
DateTime d;
obenitiypersonal.reference_date =
(DateTime.TryParse(Txt_reference_date.Text, out d))
? d
: null;
Basically you cannot get a valid
DateTime
value out of
DBNull.Value
, like you do.