asp.net - Format integer to date in eval function in RadGrid Template -


this item template

<asp:label id="lbldf" runat="server" text='<%# eval("datelong","{0:d}")%>'></asp:label> 

how can convert datelong(which returns int) date format(mm/dd/yyyy)? know there workaround in codebehind. possible using other functions inside code block?

thanks in advance

you can try this...

<asp:label id="lbldf" runat="server" text='<%#convert.todatetime(  eval("datelong")).tostring("mm/dd/yyyy") %>'></asp:label> 

edit datelong in integer..

 <asp:label id="lbldf" runat="server" text='<%#  datetime.parseexact(eval("datelong").tostring(), "yyyymmdd",//specify format in date stored in database  system.globalization.cultureinfo.invariantculture).tostring("mm/dd/yyyy"); %>'></asp:label> 

edit2 datelong in formate of difference of days given default date of db..

 <asp:label id="lbldf" runat="server" text='<%#         convert.todatetime("1890-01-01").adddays(3652+convert.toint32(eval("datelong"))).tostring("mm/dd/yyyy")         %>'></asp:label> 

Comments

Popular posts from this blog

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -