[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")))) %>'>
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
Re: forcing currency format
it doesnt work at all if i dont convert it
Re: forcing currency format
this doesn't work??? what exception does it throw?
vb Code:
String.Format("{0:$#,###,###.00}",DataBinder.Eval(Container, "DataItem.dcmPriceRange"))
Re: forcing currency format
no if i enter 123.45 it rounds to 123.00 still
Re: forcing currency format
how are you storing the data in the database.... ie what's the data type?
Re: forcing currency format
decimal it never works as a string, ive been down that road for about 2 weeks
Re: forcing currency format
ok so you're storing it as a decimal... whats the precision?
ie
MyVariabl Decimal(9,2)
Re: forcing currency format
srry the variable in my code is a douible its stored in the db as a decimal tho
Re: forcing currency format
i cant seem to set the precision even if its a decimal is this a function in the database?
Re: forcing currency format
what db engine are you using? also have you tried changing the variable in your code to a decimal type?
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 ! ^_^"