I am storing a currency with the decimal data type.
public decimal money { get; set; }
I want to display this with a "£" sign. so I am using
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:c}")]
This works fine. The value is displayed in a table with is serialized using jQuery.
@Html.EditorFor(model => model.money, "Currency")
Once the information is serialized I then make an ajax post to get the information back to my ActionResult.
Data = $('#container :input').serialize();
public PartialViewResult EditedValue(MoneyModel viewModel)
{
return PartialView("_MoneyView", viewModel);
}
This MoneyModel object contains the decimal money. THE PROBLEM, money is converted to a string in the view and when it is serialized it remains as a string. This can not be cast to a decimal in the MoneyModel.
How should I resolve this issue? I would like to keep the "£" and the "," for a formatted currency "£1,000" but I do not want to have conver decimal money -> string money in MoneyModel.