I have a column in my database with dates stored as string in the following format:
- 2/6/2018
- 5/9/2018
In my winform, I am using a DataGridView
, which is linked to a DataSet
.
On a cell_click event I want to extract the string from the respective column in the datagridview (studentstudentbirthdateDataGridViewTextBoxColumn) and parse it into a DateTimePicker element.
This is my code:
string dateTimeString = row.Cells["studentstudentbirthdateDataGridViewTextBoxColumn"].Value.ToString();
dateStudentBirthdate.Value = DateTime.ParseExact("dd/MM/yyyy", dateTimeString, CultureInfo.InvariantCulture);
However, when I initiate the event I get the following error:
String was not recognized as a valid `DateTime`.
Any clues what is it that I am getting wrong?