我想知道如何将listview
对象转换为datetime
。是否有办法做到这一点前端标记页面?
下面是我的listview
功能部分代码。下面的代码不能正常工作。
<asp:ListView ID="listviewAttachments" runat="server">
<ItemTemplate>
<tr class="announcementPost">
<td class="posted">
<h6>Convert.ToDateTime(Eval("DateModified")).Day<span><asp:Label ID="Label1" runat="server" Text='<%# Convert.ToDateTime(Eval("DateModified")).Month %>' /> </span></h6>
</td>
您没有将ListView对象强制转换为DateTime。你正在做的是试图将你的一个属性转换为DateTime
试试这个:
<%=Convert.ToDateTime(Eval("DateModified")).Day %>