I have a datetimepicker and i save the date selected with a Save Button in my SQLServer with this code. For some reason i need to have a nullable DateTime:
clienteAdd.DataLead = string.IsNullOrEmpty(form["dataLead"]) ? (DateTime?)null : DateTime.Parse(form["dataLead"]);
The save function works fine, the problem is when i set the datetimepicker loaded. I recover the data from SQLServer with this code:
var elemento = new{ dataLead = clienteLead.DataLead }
I sent 'elemento' to the view from JQuery and i set the datetimepicker:
$('#dataLead').datepicker('setDate', (new Date(result.dataLead)));
When i set 'dataLead' i have NaN as date. I know the problem is the conversion of datetime but i don't know how to save and after load this data.
Thanks to all