0

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?

4

1 回答 1

1

Try:

Html.DisplayFor(y => y.Data.Select(z => z.Name).First().ToString())

That Will Show The Value Instead of the property name.

于 2013-11-12T17:36:31.997 回答