1
Simple question:
I have a currency decimal field on my model. It happens that when I insert a decimal value in the form field, it arrives as integer in the Controller:
Example:
Value of KM Wheelset: 0.41 Arrives in 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. Exchange the "." for ","?