I have tried both this:
[Display(Name = "Contract Value")]
[DisplayFormat(DataFormatString = "{0.##}")]
public decimal ContractValue { get; set; }
And this:
[Display(Name = "Contract Value")]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0.##}")]
public decimal ContractValue { get; set; }
View:
@Html.LabelFor(x => contractInfoModel.ContractValue)
@Html.TextBoxFor(x => contractInfoModel.ContractValue, new { maxlength = "100" })
If I do this, it works. But I don't want to do this:
<input type="text" name="@Html.NameFor(x=>contractInfoModel.ContractValue)" id="@Html.IdFor(x=>contractInfoModel.ContractValue)" value="@Model.ContractInfoM.ContractValue.ToString("0.##")" class="numeric" maxlength="10" />
The Display Name works great. But it still shows 4 decimal places. What am I doing wrong?
Thanks!