I have a textbox from which I am sending date as string in 'MM/dd/yyyy' formate, and when I am assigning that value to nullable datetime property value getting the error as string was not recognized as a valid datetime, I am converting the string as below then also getting the same error
private Tbl_UserDetails GetAnnouncementInformation(Tbl_UserDetails userDetails, Dictionary<string, object> details)
{
userDetails.JoiningDate = string.IsNullOrEmpty(details["JoiningDate "].ToString()) ?
(DateTime?)null :
DateTime.ParseExact(details["JoiningDate "].ToString(),
"MM/dd/yyyy", null);
userDetails.JoiningDate = string.IsNullOrEmpty(details["JoiningDate "].ToString()) ?
(DateTime?)null :
DateTime.ParseExact(details["JoiningDate "].ToString(),
"MM/dd/yyyy", CultureInfo.InvariantCulture);
}
In both the way I am getting the same error. Please help me in this.