我想弄清楚如何改变日期时间格式,所以日期会显示出来。如何在asp.net中更改DataBinder.Eval的日期格式?
<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>
我猜这件事情在<%%>之间,但我不知道。
我后面的代码是:
<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>
目前,涉及翻过看起来像这样:
什么我要找的是时间戳并在那里走了。
任何帮助表示赞赏。
编辑:
这里就是我一直在寻找:
<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>
这不起作用,因为.ToString()不能接受任何参数。 – banging