Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7565589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:11:38+00:00 2026-05-30T14:11:38+00:00

I’m currently creating forms for contracts, one of the fields is for a rebate

  • 0

I’m currently creating forms for contracts, one of the fields is for a rebate %, and has been declared a Decimal in Entity Framework.
I’m getting an issue when I enter a value there and save it.

Quick overview of the code:

EF: tblContract -> Rebate is a Decimal field.

Create/Edit view:

<%: Html.TextBoxFor(model => model.Rebate, new { @class="form-txt-normal" }) %>

I’ve tried entering numbers in different ways.

75 : when I give it something that can be parsed to an int, it saves the correct value in the field (oddly, when displayed afterwards, no decimal point is shown, just 75).

75.25 : I watched the value that is passed to the [HttpPost] Edit method (same for Create). When a decimal value is entered, the variable is null. My outputscreen shows me an Exception has occured:

A first chance exception of type 'System.Linq.Dynamic.ParseException' occurred in ContractManagementTool.DLL

I also tried 75,25 to rule out culture settings about what a decimal point/comma should be, but the same issue occurs.
I have several other fields which contains ints, they are handled in exactly the same way, with the only difference that Entity Framework knows them as Int32, not Decimal. The Int32 all work, the Decimal does not.

Am I missing something here? Can MVC not work with Decimals as it works with ints?

Further update:

I got part of it working. I haven’t altered the code (except for some jQuery, I’ll explain).

When I enter 75,25 the Rebate variable is properly passed to the method (which makes sense, as I’m in Belgium and we use , for decimal breaks :)) I added some jQuery to replace . with , when a user enters data, to make it easier.

When I post the variable, the decimal Rebate has value 75.25 (now EF takes over with its decimal point). Rebate is already in my tblContract entity that is passed to the method. I perform a db.ApplyCurrentValues(foo);

Now here’s the punch line: in my database, the value 75 is saved. No decimal point, nothing. So I can pass it to my method properly now, but I cannot save it in the database.

Final update:

I solved it. For those curious about the answer: if you don’t specify a scale of your decimal, it’s 0. I seem to remember the standard was 2 for EF, but I might be mistaken.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:11:39+00:00Added an answer on May 30, 2026 at 2:11 pm

    Found it. Entity Framework set my decimal rounding to a whole number (1.0).
    Changed standard settings, problem solved 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.