format datetime in GridView ItemTemplate?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I can't figure out how to format a Label containing a datetime value in a
GridView .

<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="JoinDate" runat="server" Text='<%# Eval("JoinDate")
%>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
I use DataTextFormatString="{0:MMM yyyy}" in a DropDownList but this won't
work with the Label.

Thanks for any suggestions.
 
The data format string is passed as a second parameter to the Eval function
call Eval("JoinDate","{0:MMM yyyy}")
 
Back
Top