How to format Date in Gridview Asp.net C#

Asked

Viewed 1,174 times

4

In Asp.net c#,

How do I convert a date in gridview coming from the bank to the format dd/mm/yyyy ? Currently it turns out like 18/05/2015 00:00:00. The guy in the column is Boundfield. I’ve tried with string.Format and DataFormatString="{0:d} and it didn’t work. Thanks in advance.

Att.

  • See this post in English that deals with the same subject. http://stackoverflow.com/questions/832691/asp-net-formatting-datetime-in-gridview

  • Already got @Pedrolaini, this way below worked, I was passing the date as string, then changed to datetime and worked. Thanks

1 answer

1


Try to use:

<asp:BoundField HeaderText="Date" DataField="MyDate" 
 DataFormatString="{0:dd/MM/yy}">
  • Paul, I tried and did not take also Dataformatstring="{0:dd/MM/yy}". Would not have any way in code ? Thanks.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.