I am trying to use @HTML.DisplayFor in @ForEach statement but not successful.
The following is my existing code:
@foreach (var cost in Model.CustomerCost)
{
<tr>
<td>@cost .CustomerName</td>
<td>@(cost.Cost!= 0 ? string.Format("{0:C}", cost.Cost) + " USD" : "-")</td>
</tr>
}
However, i am trying to replace the following line of code
<td>@(cost.Cost!= 0 ? string.Format("{0:C}", cost.Cost) + " USD" : "-")</td>
with
@HTMLDisplayFor
<td>@(cost.Cost!= 0 ? Html.DisplayFor(model => model.CustomerCost[cost].Cost + "USD":"-")</td>
What is wrong in @HTML.DisplayFor syntax?