Let me preface this by saying I have next to zero understanding of how mvc works, and most of my code was generated by visual studio. I don't even know where to look to solve this issue.
So, I created a database that includes 'price'(decimal(5,2)) as a field. When viewing the database, the price field is displayed in the format 0,00. The db has one record, with the price value as 5,25. I then had vis studio generate a model based on this database(and then controllers with views). For the most part it works; I can insert a new record via the view and store it in the db.
The issue is with the decimals. When I go to the default 'Create' view, the text field to enter price starts with the default value of 0,00. This text field then immediately shows red warning text "The field price must be a number". If I enter a number with no decimals, the record is inserted without issue. If I enter a number with a comma, I get the above mentioned warning. If I enter a number int the format 0.00(e.g 1.25) I get no warning, and can submit, but the number entered will be 0.
A similar problem is present in the default 'Edit' view. The text fields all auto-populate with data from the selected record(the one want to edit), but the price field displays in the format 0,00, and I get the same warning as above. When displaying records in the default 'Index' view, the record with 5,25 price displays correctly in the format 0,00.
I have zero attachment to either format, I just want consistency, and the ability to input numbers with decimals. Some of my code:
The input in the edit/create views (identical in both):
<div class="form-group">
<h4>
<strong>Price</strong>
</h4>
<input asp-for="ItemPrice" class="form-control" />
<span asp-validation-for="ItemPrice" class="text-danger"></span>
</div>
The declaration of the price field in the model:
public decimal ItemPrice { get; set; }