The .#### is normal for money types in SQL Server. For output in an ASP.NET
app, you can use DataBinder.Eval to output. The number will still have 4,
but only show 2.
<%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}") %>
This involves late binding, and may not work for all situations. Now, if you
wish to include the $ or other country formatting, you can do this trick:
CurrencyLabel.Text = doubleVal.ToString("C",
Thread.CurrentThread.CurrentCulture);
If it is always dollars, you can use:
CurrencyLabel.Text = doubleVal.ToString("C", new CultureInfo("en-us"));
NOTE that I am using a double here. If you use
System.Data.SqlTypes.SqlMoney, you will ALWAYS have a precision of 4.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Mark Fox" <in**@solelsoftware.com> wrote in message
news:10****************************@phx.gbl...
Hello,
I have a "smallmoney" field in SQL Server that I am
attempting to display, but when I use the .ToString()
method on a decimal variable it displays too many places
after the decimal point (i.e. more than two). I know
there's a string I could use as an argument for ToString
() that will only display the first two deigits after the
decimal point, does anyone know what that is? Thanks for
your help!
decimal AccountTotal = 4.7300;
string myString = AccountTotal.ToString("????");