-1
I have a register, where I have some fields to enter values, but the same only accepting integer number, if add some value with decimal passes zero.
Controller
[Display(Name = "Valor Multiplicador para Opção 01:")]
[DisplayFormat(DataFormatString = "{0:0,0.00}", ApplyFormatInEditMode = true)]
public double VALOR01 { get; set; }
View
<!-- language: lang-html -->
@using (Html.BeginForm("Index", "CadastroPossibilidade", FormMethod.Post))
{
<div class="row">
<div class="container">
<div class="col-md-3 form-group">
@Html.HiddenFor(c => Model.IDPOSSIBILIDADE)
@Html.LabelFor(c => Model.DESCRICAO01)
@Html.TextBoxFor(c => Model.DESCRICAO01, new { placeholder = "descrição", @class = "form-control" })
</div>
<div class="col-md-3 form-group">
@Html.LabelFor(c => Model.VALOR01)
@Html.TextBoxFor(c => Model.VALOR01, new { placeholder = "0", @class = "form-control" })
</div>
<div class="col-md-3 form-group">
@Html.LabelFor(x => x.IDTITULOPOSS)
@Html.DropDownListFor(x => x.IDTITULOPOSS, ViewBag.TituloPos as SelectList, new { @class = "form-control" })
@Html.ValidationMessageFor(x => x.IDTITULOPOSS)
</div>
</div>
</div>
}
Do not use
double
for decimal representation. Usedecimal
.– Leonel Sanches da Silva