Reputation: 997
I have a gridview and sqldatasource. In my regional settings in cp , date format is set to dd.MM.yyyy .
I have in my gridview a column with type date. In the gridview if I set a value to the cell in format dd.MM.yyyy
`I get Conversion failed when converting date and/or time from character string`.
But if I type a date in format MM.dd.yyyy it works , but I don't really understand why it happenes? and also If I set dd.MM.yyyy date format , manually in the table, it works.
The column is itemtemplate and the control of the column wasn't edited .
Upvotes: 0
Views: 1005
Reputation: 7591
mm refers to minutes MM refers to the day. here is one reference on different formats available: http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm
Upvotes: 1
Reputation: 2275
You need to specify the format of date into GridView.
<asp:BoundField DataField="fieldname" HeaderText="Header text" ReadOnly="True"
SortExpression="fieldname" HtmlEncode="False" DataFormatString="{0:d}" / >
Upvotes: 0
Reputation: 1921
myDate.ToString("dd-MM-yyyy")
refer here : How to convert date format to DD-MM-YYYY in C#
Upvotes: 0