开发者

How to display DateTime with just the date component

<asp:Label ID="dateLabel" runat="server" Text='<%# Eval('SomeDate') %> />

This displays showing the date and time. However I just want to display the date.

I'm aware that in the code behind you can write SomeDate.ToString("dd MM yyyy");

However I want a way of 开发者_JAVA百科doing this by changing the code in the tag instead.

Is this possible?


Try <%# Eval("SomeDate","0:dd-MMM-yyyy") %> or of course any date format you like.


Not really an answer to your requirement, but in you code behind you can also do

string formattedDate = SomeDate.ToShortDateString();

and in your tag, just display the formatted date

<asp:Label ID="dateLabel" runat="server" Text='<%# Eval('formattedDate') %> />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜