在Gridview的模板领域中使用Datavale进行标签绑定时如何设置日期格式 [英] At time of Label binding with datavale in Template feild of Gridview How to set Date format
本文介绍了在Gridview的模板领域中使用Datavale进行标签绑定时如何设置日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Gridview的模板领域中使用Datavale进行标签绑定时,如何设置日期格式
At time of Label binding with datavale in Template feild of Gridview How to set Date format
推荐答案
您好,
这是一个示例:
Hi,
Here is an example:
<ItemTemplate>
<asp:TextBox id="txtCloseDate" Text='<%# Eval("CloseDate","{0:dd/MM/yy}") %>' runat="server" />
</ItemTemplate>
您也可以在代码后面使用方法格式化它:
You can format it using a method in your code behind too:
<ItemTemplate>
<asp:Label
ID="BeginDateLabel"
runat="server"
Width="80px"
Text='<%# DateFormatter((DateTime)Eval("BeginDate")) %>'>
</asp:Label>
</ItemTemplate>
in your codebehind:
protected string DateFormatter(DateTime date)
{
return date.ToShortDateString();
}
希望对您有所帮助,
干杯.
I hope it will help,
Cheers.
这些链接应该可以帮助您-
http://www.dotnetspark.com/links/16749-format-datetime-templatefield.aspx [^ ]
http://www.codedigest.com/Articles/ASPNET/137_How_to_format_DateTime_in_GridView_BoundColumn_and_TemplateColumn.aspx ^ ]
These links should help you out -
http://www.dotnetspark.com/links/16749-format-datetime-templatefield.aspx[^]
http://www.codedigest.com/Articles/ASPNET/137_How_to_format_DateTime_in_GridView_BoundColumn_and_TemplateColumn.aspx[^]
尝试:
<ItemTemplate><asp:Label ID="lblDOB" runat="server" Text='<%# Eval("DOB","{0:d}") %>'></ItemTemplate></asp:TemplateField>
有关更多信息,请参见:
http://www.bloggerindia.in/date-format-in -gridview-using-asp-net-2-0/ [ http://gridview-date-format.blogspot.in/ [
for more refer:
http://www.bloggerindia.in/date-format-in-gridview-using-asp-net-2-0/[^]
http://gridview-date-format.blogspot.in/[^]
这篇关于在Gridview的模板领域中使用Datavale进行标签绑定时如何设置日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文