Doubt BoundField

P

Paulo

Why when I put on DataFormatString: {0:dd/MM/yyyy} on a boundfield at the
gridview it lists: 24/01/1981 00:00:00 and I want just Date...

Can you help me ?
C# 2.0 VS 2005 asp.net
 
G

Guest

Hi Paulo,
what source of data are you using for your grid view? Is it a database? If
so what is returining your query and especially what type is used for your
date type. It has to be DateTime.

Regards,
Ladislav
 
P

Paulo

Thanks for replying, the source came from a sql serve, and the field type is
DateTime...

Thanks
 
G

Guest

Hi Paulo,
you can use this workaround:
<asp:TemplateField HeaderText="Date">
<ItemTemplate>
<asp:Label runat="server" ID="myDate" Text='<%#
((DateTime)Eval("Last_Update")).ToString("dd/MM/yyyy") %>' />
</ItemTemplate>
</asp:TemplateField>

I am using all fields except TemplateField very rarely.

Regards,
Ladislav
 
G

Guest

Hi again Paulo,
I tryed it at my own and I found a trick :) Set HtmlEncode="false" for your
BoundField.

Regards,
Ladislav
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top