如何转换列表视图对象

发布于 2024-12-15 08:45:23 字数 588 浏览 2 评论 0原文

我想知道如何将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽清梦 2024-12-22 08:45:23

您没有将 ListView 对象强制转换为 DateTime。您正在做的事情是尝试将您的属性之一转换为 DateTime

尝试以下操作:

<%=Convert.ToDateTime(Eval("DateModified")).Day %>

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:

<%=Convert.ToDateTime(Eval("DateModified")).Day %>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文