• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 734
  • Last Modified:

Formatting Date, Ect. when using Eval("FieldName")

Here is my code:

<asp:Repeater ID="Repeater1" runat="server">
   <ItemTemplate>
           <ul>
                <li class="postdate"><%#Eval("DatePosted"))%> </li>
                <li class="posttitle"><%#Eval("BlogEntryTitle")%> </li>
                <li class="postcontent"><%#Eval("BlogEntry")%> </li>
                <li class="postedby">posted by <%#Eval("PosterId")%>  @ <%#Eval("DatePosted")%> </li>
           </ul>
   </ItemTemplate>  
</asp:Repeater>

Repeater is databound via SP in code behind.

How do I format the dates here?  

First I want just the date in the format mm/dd/yyy
Secondly I want just the time the from the DatePosted EX : 9:46 AM

any ideas?

Thanks,
Max
0
alivemedia
Asked:
alivemedia
  • 3
1 Solution
 
pauljk1619Commented:
<li class="postdate"><%#Eval("DatePosted", "{0:MM/dd/yy}")%> </li>
<li class="postdate"><%#Eval("DatePosted", "{0:hh:mm tt}")%> </li>
0
 
pauljk1619Commented:
By the way, if this doesn't work, you may have to remove the DataSourceID from your Repeater, so you can use an DataBinder.Eval which contains the arguements for formatting thte string.
0
 
alivemediaAuthor Commented:
perfect, thanks!
0
 
pauljk1619Commented:
If you are using as sqldatasource you can format the bound columns....

http://msdn2.microsoft.com/en-us/library/h73k0a97.aspx

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now