如何在gridview中绑定时格式化日期时间
我有一个 DateTime 类型的字段,它绑定在 gridview 中。
现在,我想仅显示该字段中的日期,而不是时间。
日期应采用 1/1/0001
这种格式。
我正在使用 DotnetNuke
我的代码如下
<asp:TemplateField HeaderText="Created On">
<itemtemplate>
<%#DataBinder.Eval(Container.DataItem, "Alb_Created_Date","0:dd/MM/yyyy}")%>
</itemtemplate>
</asp:TemplateField>`.
我已尝试使用的格式,但其输出如下 1/1/0001 12:00:00 AM。
我该怎么办?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您缺少左尖括号
{
。试试这个。You are missing an opening angular brace
{
. Try this.在您的代码中,您在格式中给出了错误的语法,因此它的格式不正确并给出了数据库值本身。请按如下格式设置。
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.