Assuming hdndate.Value
is actually a string and its value is "28/04/2014"
:
Replace this:
Convert.ToDateTime(hdndate.Value)
With this:
DateTime.ParseExact(hdndate.Value, "dd/MM/yyyy", CultureInfo.InvariantCulture);
DateTime.ParseExact
allows you to specify the exact format of your input string, so that it can correctly generate a DateTime
from it. In this case, your format is dd/MM/yyyy
.
solved String was not recognized as a valid DateTime from DateTimePicker