I am getting following error:
Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.
When I try to use:
@Html.DisplayFor(modelItem => Html.Raw(item.ChangesMade))
in my asp.net MVC 3 view.
Can you please suggest correct syntax ?
UPDATED
You can’t use the HTML.DisplayFor helper TEMPLATE with an HtmlString like that which is returned from Html.Raw.
Instead, assuming your item.ChangesMade contains raw HTML that is useful try just
OR (more likely) if ChangesMade is just a value then use the Html helper:
The easiest way for simple properties is to use the Templated Helpers (EditorFor, TextboxFor, etc) because they will utilize any DataAnnotation attributes you’ve used in your model classes — especially important with built-in validation!
For example:
So you could use the Templated Helper if item.ChangesMade is a simple type and can be expressed by a (Textbox, Checkbox, Textarea, etc).
You might also use in combination with built-in validation:
Hope that helps!