I am getting a "Value cannot be null" error from the code below:
@Html.Label(material.ExtendedGroup)
ExtendedGroup
is indeed null
, but I would like to know how handle this with Razor's HTML helper -- something equivalent to Isnull(material.ExtendedGroup,"",material.ExtendedGroup)
that we do in MS SQL. Please suggest a solution.
The null coalescing operator would do the trick:
@Html.Label(material.ExtendedGroup ?? "default value")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With