title: How to programmatically assign the date to a datetimepicker from a database in c#
body: <p>i hav a datetimepicker control whose format i have set to custom as dd/mm/yyyy (with no time). i store this date in a database as varchar and not as datetime because it was giving some sort of error regarding invalid datetime format. i then use a datagrid to display the records from the database. the thing is i need to retrive the date from the datagrid (when the user selects the particular date cell in datagrid)  and want to display it back on the datetimepicker control (so that the user can edit it). i am using the following code to do so:
  dtDate.Value = Convert.ToDateTime(dgDetails.SelectedCells[1].FormattedValue);</p>
  
  <p>the error i am getting is "String was not recognized as a valid DateTime".
  where the dtDate is datetimepicker control, dgDetails is the datagrid and SelectedCells[1] is the cell containing the date.</p>