date format

mstislavshglhn

New Member
Does anyone know how I can format a date when accessing it like...<%# Databinder.Eval(Container.DataItem, "EffDate") %> inside a template column of a datagrid? I can use <asp:BoundColumn DataField="StartOfCare" HeaderText="Start of Care" DataFormatString="{0:d}"></asp:BoundColumn> when I have a bound column.You can call functions inside a databinding statemetns <%# %>. I think formatdatetime is what you need. <BR><BR><%# FormatDateTime(Databinder.Eval(Container.DataItem, "EffDate"),2) %><BR><BR>Not sure if thats the best way... But it works.That is one way to do it. Another is to use another form of the DataBinder.Eval method. See:<BR>ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemwebuidatabinderclassevaltopic2.htm<BR><BR>You can use:<BR><BR><%# DataBinder.Eval(Container.DataItem, "ColumnName", "FormatString") %><BR><BR>hth!
 
Back
Top