Format Dates using Repeater Control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello -

I am pulling a datetime var from a dataset which is binded to a repeater
control as follows:

<%# DataBinder.Eval(Container.DataItem, "DateCreated") %>

The datetime value returns fine, but is not formated. How can i format this
"inline code"? I am aware that this can be done using code-behind,
specifically using the ItemDataBound event, but i'd like to learn how i can
format dates, if possible, right in the above linem using the DataBinder
method.

Thanks,
 
Try this:

<%# System.Convert.ToDateTime (DataBinder.Eval(Container.DataItem,
"DateCreated")) .ToString ("MM-dd-yyyy") %>

Eliyahu
 
Back
Top