I am creating a table in my Razor view that if a bool value is true then show an asterick next to one of the fields. The code I have looks correct but it is coming out blank on all rows. It should be the number in that field if false and the number in that field* if true.
Here is the code:
@{
string ToDisplay = item.MinimumOnHandQuantity.ToString();
if (item.UseForecast)
{
ToDisplay += "*";
}
}
@Html.Display(ToDisplay)
Try this
@{
string ToDisplay = item.MinimumOnHandQuantity.ToString();
if (item.UseForecast)
{
ToDisplay += "*";
}
}
@Html.Raw(ToDisplay)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.