Hi,
I have the following get and set for displaying a date on my webpage. It’s a null value
However, when I go to load the page I get an error on the set part saying the “Nullable object must have a value.”
Can anyone see where I’m going wrong and how to fix this.
Thank you very much
public DateTime? Date
{
get
{
if (txtDate.Text != "")
{
return Convert.ToDateTime(txtDate.Text);
}
return null;
}
set{ txtDate.Text = value.Value.ToShortDateString(); }
}