I am getting an error 'String was not recognized as a valid DateTime.' by using the following code.
NewRow["ExpiryDate"] = DateTime.ParseExact(SelectedRow.Cells[9].Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
where selectedRow is row of database. The code is written in RowCommand event. Value in SelectedRow.Cells[9].Text is in dd-MM-yyyy format on client side where as it is different on server side.
How can I write generic code that will work for all datetime format?