如何强制转换listview对象



我想知道如何将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 %>

相关内容

最新更新