I am sorry for posting this question as it may be find silly to all, but I am not getting the exact solution.
The question is: I have a Date time picker in my proje
There is no direct solution to empty DateTimePicker
. Only way to empty DateTimePicker is to set CustomFormat
and then set empty space
as value.
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = " ";
Even if you do it value will be cleared in the control but if you access the value property of the control in code it will return the current date time. So your condition will always be false.
//This is always false
dateInsert.Value.ToString() = string.Empty
SOLUTION
Instead of using Value
use Text
in the condition.
if(dateInsert.Text = " ")