I am using an if else in Razor view to check for null value like this:
@foreach (var item in Model)
{
-
I think you want to display "-----" if amount is null.
@foreach (var item in Model)
{
@Html.DisplayFor(modelItem => item.Name)
@if (item.Amount == null)
{
@Html.Raw("--")
}
else
{
String.Format("{0:0.##}", item.Amount);
}
}
- 热议问题