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>
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: