Click to See Complete Forum and Search --> : [Asp.net/C#] Inserting date into a template field


fogofogo
08-02-2007, 05:08 AM
Hello,

probably an easy one for most, but I'm trying to grab todays date and insert it into a lable in a template field

<asp:TemplateField HeaderText="ProcessedDate">
<ItemTemplate>
<asp:Label ID="lbldatetoday" runat="server" Text="<% = DateTime.Now().ToString() %>"></asp:Label>
</ItemTemplate>
</asp:TemplateField>

the codes wrong, does anyone know what it should be? also is it possible to format it to yymmdd?

Would I be better off to use findcontrol?

Thanks

lmf232s
08-02-2007, 08:47 AM
Try this

Text='<%# Date.Now().ToString("yy/dd/MM") %>'

fogofogo
08-03-2007, 05:12 AM
cheers!