Reputation:
I am new in ASP.NET and I am trying to convert True/False value to Yes/No.
<th>
Arbitration
</th>
<td>
@Html.DisplayFor(modelItem => item.Arb)
</td>
What is the best way to do it ?
Upvotes: 0
Views: 531
Reputation: 16811
One option is to use an extension
NFdocs.Models
{
public static class BoolExt
{
public static string ToYesNo(this bool? val) => (val ?? false) ? "Yes" : "No"; }
}
}
Then in view
@using NFdocs.Models
<span>@item.Arb.ToYesNo()</span>
Upvotes: 2