Reputation: 6918
I have a field of type DateTime which is bound in gridview.
Now, i would liketo display only date from this field, and not time.
Date Should be in 1/1/0001
this format.
I am using DotnetNuke
My code is as follows
<asp:TemplateField HeaderText="Created On">
<itemtemplate>
<%#DataBinder.Eval(Container.DataItem, "Alb_Created_Date","0:dd/MM/yyyy}")%>
</itemtemplate>
</asp:TemplateField>`.
I have tried the format that is used but its output is like this 1/1/0001 12:00:00 AM.
What shall I do?
Upvotes: 3
Views: 9180
Reputation: 11844
In your code you have given wrong syntax in the format, and due to which its not formatting correctly and giving out the data base value itself. Please, format it as below.
<%#DataBinder.Eval(Container.DataItem, "Alb_Created_Date","{0:dd/MM/yyyy}")%>
Upvotes: 2
Reputation: 55200
You are missing an opening angular brace {
. Try this.
<asp:TemplateField HeaderText="Created On">
<itemtemplate>
<%# DataBinder.Eval(Container.DataItem, "Alb_Created_Date", "{0:dd/MM/yyyy}")%>
</itemtemplate>
</asp:TemplateField>
Upvotes: 3