Simple question:
I have a Decimal field of type Currency in my model. It happens that when I enter a decimal value in the form field, it arrives as integer in the Controller:
Example:
KM Value Rounded: 0.41 Arrives on Controller: 41
My Model:
[Required]
[Display(Name = "KM")]
[DataType(DataType.Currency, ErrorMessage = "Valor deve ser uma quantia de dinheiro válida")]
[Range(0.01, 9999.00)]
public double ValorKM { get; set; }
My Controller:
ModelState.Remove("URLFoto");
if (ModelState.IsValid)
{
db.Entry(frota).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
My Form:
<div class="col-md-12">
<div class="col-md-2">@Html.LabelFor(model => model.ValorKM)</div>
<div class="col-md-2">
@Html.TextBoxFor(model => model.ValorKM, new { type = "text" })
@Html.ValidationMessageFor(model => model.ValorKM)
</div>
</div>
Another question is how do I change my decimalSeparator. Change the "." by ","?