Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
520
'Nullable' WebDatePicker
posted

I just realized that when using a nullable (Nullable=true) WebDatePicker I cannot do this:

 

 

DateTime? a = null;

...

this.WebDatePicker1.Date = a; 

 

Therefore, I am forced to do the following:

 

 

if (a.HasValue)

 {

        this.WebDatePicker1.Date = a.Value;

}

else

{

       this.WebDatePicker1.Date = new DateTime();

}

 

Is there any way to take advantage of the nullable property of the control or am I stuck with the above?

 

 

  • 24497
    posted

    Hi bpg730,

    The Date property of WebDatePicker has type of DateTime. It was designed for application which need accessor of that particular type (without typecast).

    The main property of WebTextEditor and all its extensions is Value which has type of object.

    this.WebDatePicker1.Value = a;