How to display decimal with 3 zeros after comma, without trailing? My code is
<td>@decimal.Parse(item.QuantityKg.ToString()).ToString("G29")</td>
How to display decimal with 3 zeros after comma, without trailing? My code is
<td>@decimal.Parse(item.QuantityKg.ToString()).ToString("G29")</td>
Since your QuantityKg is decimal? instead of decimal, you can use it's Value property and use "N" format specifier with 3 precision.
If everything is okey other than this, this should work in your case;
<td>@item.QuantityKg.Value.ToString("N3")</td>
But this throws InvalidOperationException if QuantityKg is null, so using string.Format would be better to catch this situation which generates empty string if it is null as Panagiotis mentioned.
<td>@string.Format("{0:N3}", item.QuantityKg)</td>