Saturday, February 5, 2011

SharePoint DateTime control returning current date when no date is selected

In WSS 3.0/4.0, I am using sharePoint DateTime control. I retrieve the date selected by the user using SelectedDate property of the sharePoint DateTime control.

The issue is that even when the user has not selected any date in the sharePoint DateTime control, the SelectedDate property of the sharePoint DateTime control returns current date.

Solution :

if (dt.IsDateEmpty)
{
objdt = DBNull.Value;
}
else
{
objdt = dt.SelectedDate.ToString();
}