如何转换列表视图对象
我想知道如何将 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>
I'm wondering how to cast a listview
object to a datetime
. Is there a way to do this on front end markup page?
Here's my code below from part of the listview
functionality. This code below doesn't work properly.
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有将 ListView 对象强制转换为 DateTime。您正在做的事情是尝试将您的属性之一转换为 DateTime
尝试以下操作:
You are not casting a ListView object to DateTime. What you are doing there is trying to cast one of your properties to DateTime
Try this: