|
-
May 30th, 2007, 12:43 PM
#1
Thread Starter
Addicted Member
[RESOLVED] forcing currency format
ok so i got my currency formatting working to where it doesnt store $'s and ,'s in the DB but dispays them in the output from the DB
BUT now.....
no its rounding them up and down.... it wasnt doin this at first.... it just suddenly changed.... it would truncate from 12.345 to 12.34 and stuff but now if you enter 12.34 it rounds to 12.00 and im witting here like ***???
heres the code for both columns
asp.net (1.1) Code:
<asp:Label ID=dcmPriceRange runat="server" Text='<%# String.Format("{0:$#,###,###.00}",(Convert.ToDouble(DataBinder.Eval(Container, "DataItem.dcmPriceRange"))))%>'>
<asp:Label runat="server" ID="PriceRangeS" Text='<%# String.Format("{0:C2}",(Convert.ToDecimal(DataBinder.Eval(Container, "DataItem.dcmPriceRange")))) %>'>
-
May 30th, 2007, 01:09 PM
#2
Re: forcing currency format
try not converting the values to double and decimal. String.Format takes a value of type Object so let String.Format do the conversion
-
May 30th, 2007, 01:10 PM
#3
Thread Starter
Addicted Member
Re: forcing currency format
it doesnt work at all if i dont convert it
-
May 30th, 2007, 01:13 PM
#4
Re: forcing currency format
this doesn't work??? what exception does it throw?
vb Code:
String.Format("{0:$#,###,###.00}",DataBinder.Eval(Container, "DataItem.dcmPriceRange"))
-
May 30th, 2007, 01:16 PM
#5
Thread Starter
Addicted Member
Re: forcing currency format
no if i enter 123.45 it rounds to 123.00 still
-
May 30th, 2007, 01:17 PM
#6
Re: forcing currency format
how are you storing the data in the database.... ie what's the data type?
-
May 30th, 2007, 01:17 PM
#7
Thread Starter
Addicted Member
Re: forcing currency format
decimal it never works as a string, ive been down that road for about 2 weeks
-
May 30th, 2007, 01:20 PM
#8
Re: forcing currency format
ok so you're storing it as a decimal... whats the precision?
ie
MyVariabl Decimal(9,2)
-
May 30th, 2007, 01:25 PM
#9
Thread Starter
Addicted Member
Re: forcing currency format
srry the variable in my code is a douible its stored in the db as a decimal tho
-
May 30th, 2007, 01:31 PM
#10
Thread Starter
Addicted Member
Re: forcing currency format
i cant seem to set the precision even if its a decimal is this a function in the database?
-
May 30th, 2007, 01:33 PM
#11
Re: forcing currency format
what db engine are you using? also have you tried changing the variable in your code to a decimal type?
-
May 30th, 2007, 01:38 PM
#12
Thread Starter
Addicted Member
Re: forcing currency format
ah thx man it was because we just igrated from sql server enterprise 2003 to 2005 and it changed alot of crap i changed it to decimal(18,2) now thx ! ^_^"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|