0

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 .

Jax
  • 977
  • 8
  • 22
  • 40

3 Answers3

1

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

Jason Meckley
  • 7,589
  • 1
  • 24
  • 45
0
myDate.ToString("dd-MM-yyyy")

refer here : How to convert date format to DD-MM-YYYY in C#

Community
  • 1
  • 1
SP007
  • 1,871
  • 1
  • 22
  • 31
  • I'm not inserting something to format the date. I'm just updating the info from the gridview – Jax Jun 19 '12 at 18:54
0

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}" / >
Saroop Trivedi
  • 2,245
  • 6
  • 31
  • 49