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 - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -