I show the Guarantor name inside the foreach statement using the Html.LabelFor helper.
However, I do not get the expected result.
Instead of displaying the actual value of the GuaranterName name, it simply prints as follows: The label value indicates the actual name of the field, which is: GuarantorName, while I need the actual name value for this field (for example, "Bill Yeager"), which I checked during debugging, has various different names.
During debugging, I see in my list that I have the actual names in the collection.
How can i do this?
Here is my look in the code:
@foreach (var item in Model.Guarantors) { <td> @Html.CheckBoxFor(model => item.isChecked) @Html.LabelFor(model => item.GuarantorName) </td> }
If I try this, I get the following error:
@Html.DisplayFor(model => item.GuarantorFirstName + item.GuarantorLastName)
Exception Details: System.InvalidOperationException: Templates can only be used with field access, resource access, one-dimensional array index, or one-parameter custom indexer expressions.
Source Error: Line 95: <td> Line 96: @Html.CheckBoxFor(model => item.isChecked) Line 97: @Html.DisplayFor(model => item.GuarantorFirstName + item.GuarantorLastName) Line 98: </td> Line 99: }
source share