class NullableDateTimePicker : DateTimePicker
{
[Bindable(true)]
public object DBValue
{
get
{
if (this.Checked)
return base.Value;
else
return System.DBNull.Value;
}
set
{
if (System.Convert.IsDBNull(value))
this.Checked=false;
else
this.Value = Convert.ToDateTime(value);
}
}
}
Though in the ideal case it should be solved at the databinding level instead of the custom control.
No comments:
Post a Comment