I have a gridview and a SqlDataSource.
In the SqlDataSource‘s update statement I’m trying to convert the string of the column to datetime with this:
Date = Convert(DateTime, @Date, 104)
//this converts the string to mm.dd.yyyy .
I can’t find the code for mm.dd.yyyy hh:mm .
Your questions states you are using a GridView and a DataSource.
I’m assuming your source data is in a DateTime format in SQL Server.
If so, leave it in that format, otherwise, cast it as a DateTime when returning it.
Do NOT try converting it into a string on the SQL Server end or run a pass over your DataTable and convert it to a string using C#. That is the wrong approach to this.
All you need to do is set the DataFormatString on your GridView’s BoundField column like so: