Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here's the problem:

a date formatted in Configuration.cs as this:

EventStartDateTime=DateTime.Parse("2/16/2008 12:15:12 PM")

then showing in the Db table as this:

2008-02-16 12:15:12.000

and when coming into the Index.cshtml here:


@Html.DisplayFor(modelItem => item.EventStartDateTime)


at the break, the hover over shows this:

item.EventStartDateTime.Date {2/16/2011 12:00:00 AM}

but the page crashes and gives this error message:

"
Exception Details: System.FormatException: Input string was not in a correct format.
"

????

what is going on here?

What I have tried:

i tried stringing it as:


@Html.DisplayFor(modelItem => item.EventStartDateTime.ToLongDateString())


but i get this error msg, which i do not understand at all.

"Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions."

also, when i tested the date string in the MS sample console project, it worked as expected, which left me totally confounded.

is the error in something Razor wants, or ???
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900