<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') %> />
精彩评论