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

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

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

ios - I get the error Property '...' not found on object of type '...' -