In my entity framework model (from oracle) I have a table that contains the following Column
Now. I use an asp.net webforms datagrid to view the data. At one stage the value in this column is 635838861561284513. I do (in theory) send this value through as a parameter on the url when I click a custom link on this grid. The value is added to the url as follows:
<a href="javascript:Cover(<%# Eval("BATCH_NO") %>);">View</a>
Now I noticed upon debugging that the value "<%# Eval("BATCH_NO") %>"
comes through as 635838861561284500 and not 635838861561284513.
But the value displays correctly in the grid!!
Can anyone explain why this is happening?
Because JavaScript's numbers are IEEE-754 double-precision floating point numbers, which have 53 bits to store the unscaled value of the number (the other bits are for exponent), which translates to just under 16 decimal digits of precision. Their maximum "safe" integer value (integer value that won't lose precision) is 9007199254740991. Your 635838861561284513 is much bigger than that.
If you want to pass that number to and from JavaScript, best to keep it in a string.