在那里,我可以格式化绑定在ListView日期的方式是什么?
is there a way that I can format a Date binded in a ListView?
我有这个片段的ListView
I have this snippet of ListView
<ListView ID="lvView" runat="server">
<ItemTemplate>
//... some bounded data
<asp:Label ID="lblDate" runat="server" Text='<%# Bind("RequiredDate") %>' />
//... another bounded data
</ItemTemplate>
</ListView>
由于 RequiredDate
是的DateTime
会显示somethine这样 10/20 / 2010上午11时08分55秒
Since RequiredDate
is a DateTime
it will display somethine like this 10/20/2010 11:08:55 AM
我要的是格式化的日期输出像这样十月20日
。通常情况下,如果它是一个日期时间,我可以这样写 requiredDate.ToString(MMMM DD,YYYY)
但ListView控件绑定里面的数据我不能做到这一点。
What I want is to Format that date to output something like this Oct. 20, 2010
. Normally if it is a DateTime I can write something like this requiredDate.ToString("MMMM dd, yyyy")
but inside the ListView binded data I cannot do that.
我不希望使用OnItemDatabound。我只是希望它是格式化的内联。这可能吗?
I don't want to use OnItemDatabound. I just want it to be formatted inline. Is this possible?
应该是这样......
Should be like...
Text='<%# Bind("RequiredDate", "{0:MMM dd, yyyy}") %>'