views:

40

answers:

0

I have a MaskedTextBox control with the mask "00/00/0000", the PromptChar "_" and the ValidatingType of DateTime, bound to a DateTime column in a database that can also accept null values.

I'd like the user to have to enter either a valid date, or leave it blank (i.e. "__/__/____") for a DBNull.

By using the TypeValidationCompleted event I can determine whether a valid date was entered but I do not know how to set the value to a DBNull whenever no date, or an invalid one, is specified.

How can I get a DBNull value from the MaskedTextBox whenever validation fails?