Returning a DBNull for a bound MaskedTextBox whenever type validation fails?
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 lik开发者_如何学编程e 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?
精彩评论