In MVC Razor view, I am trying to format a DateTime field to display time only. Using below code I am getting error \"Templates can be used only with field access, property acce
You have a very simple way to solve this and you might run into this problem more than once.
To understand what's happening, you are passing a method as a parameter. Instead, you should be passing an expression.
Instead of doing this
@(Html.DisplayFor(m=>row.LastUpdatedDate.ToString("HH:mm:ss")))
You should do
var date = row.LastUpdatedDate.ToString("HH:mm:ss")
@Html.DisplayFor(m=> date)