I'm trying to figure out how to change the datetime format so just the date will show up.
<asp:Repeater ID="RepeaterActions" runat="server"> <ItemTemplate> <li> <span class="historyDate"><%#DataBinder.Eval(Container.DataItem, "ActionListDate")%></span> <span class="historyName"><%#DataBinder.Eval(Container.DataItem, "LeadActionName")%></span><br /> <span class="historyNotes"><%#DataBinder.Eval(Container.DataItem, "ActionListNote")%></span> </li> </ItemTemplate> </asp:Repeater>
I'm guessing it's something in between the <% %>, but I'm not sure.
My code behind is:
<pre> protected void RepeaterActionsFill() { string sql = @" select a.ActionListDate, a.LeadListID, a.ActionListNote, l.LeadActionName from ActionLists as a INNER JOIN LeadActions as l ON a.LeadActionID = l.LeadActionID where a.LeadListID = " + Convert.ToInt32(Request["id"].ToString()); RepeaterActions.DataSource = DBUtil.FillDataReader(sql); RepeaterActions.DataBind(); } </pre>
Currently, it comes accross looking like this:
And what I'm looking for is for the time stamp to be gone there.
Any help is appreciated.
EDIT:
Here is what I was looking for:
<asp:Repeater ID="RepeaterActions" runat="server"> <ItemTemplate> <li> <span class="historyDate"><%#DataBinder.Eval(Container.DataItem, "ActionListDate", "{0:M/d/yy}")%></span> <span class="historyName"><%#DataBinder.Eval(Container.DataItem, "LeadActionName")%></span><br /> <span class="historyNotes"><%#DataBinder.Eval(Container.DataItem, "ActionListNote")%></span> </li> </ItemTemplate> </asp:Repeater>
Solution 1Text=System. DateTime. Now. ToString("dd/MM/yyyy");
Eval) function is used to bind data in controls inside GridView, DataList, Repeater, DetailsView, etc. and using string. Format multiple values can be set to a single control.
give the format e.g:
<%# DataBinder.Eval(Container.DataItem, "ActionListDate", "{0:d/M/yyyy hh:mm:ss tt}") %>
<%# string.Format("{0:ddd MMM yyyy}", Eval("ActionListDate"))%>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With