Hello, good morning.
I have a class that has a decimal field where I save the price. So far so good. When it is displayed in the / Edit / of the page, it is also beauty. But that's the problem: 1 - The MVC (which I am using 4 with EF 6) it displays in the input the field with, 00 then when I save it does not leave informing that the format is incorrect (EF validate). 2 - If I put the .00, it passes 3 - if it is for some value of the type: 14.90 (14.90 in real) it sends to the bank 14900
How could you solve this problem?
Follow the class:
public class Opcional
{
public Opcional()
{
this.Diarias = new HashSet<Diaria>();
}
[Key]
public int OpcionalId { get; set; }
[Required]
public String Descricao { get; set; }
[Required]
public decimal Valor { get; set; }
public virtual ICollection<Diaria> Diarias { get; private set; }
}
Excerpt from my edit code:
<div class="col-md-12">
<div class="col-md-2">@Html.LabelFor(model => model.Valor)</div>
<div class="col-md-10">
@Html.EditorFor(model => model.Valor)
@Html.ValidationMessageFor(model => model.Valor)
</div>
</div>