Reputation: 1415
This Line of Code is causing the below error.
Code:
@Html.LabelFor(y => y.Data.Select(z => z.Name).First().ToString());
Error:
Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.
This is in a Razor MVC4 View.
Can this be re-written or can I not do it?
Upvotes: 0
Views: 4842
Reputation: 1798
Try:
Html.DisplayFor(y => y.Data.Select(z => z.Name).First().ToString())
That Will Show The Value Instead of the property name.
Upvotes: 1