Re: Formating currency on label

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



That is pretty much the same thing except slower :)

reader[1] returns an object that is actually has type Decimal.
Then you leave string.Format to figure it out and apply {0:c} accordingly.

with reader.GetDecimal(1).ToString("c") the guessing of which type reader[1]
is already done by you. Since GetDecimal returns Decimal.

George.


"Paulo" <eris_paulo@xxxxxxxxxxxx> wrote in message
news:OKiqRxstIHA.1220@xxxxxxxxxxxxxxxxxxxxxxx
George, I found something on google:

lblPreco.Text = string.Format("{0:c}", reader[1]);

Thank you very much!

"George Ter-Saakov" <gt-nsp@xxxxxxxxxxx> escreveu na mensagem
news:%23s6fLvstIHA.2208@xxxxxxxxxxxxxxxxxxxxxxx
"Show currency" is kind of vague....as "does not work"....I bet it works
just does not give you result you want :)

After you did reader[1].ToString() it becomes string and you can not
apply {0:c} to it. Since it only applicable to Decimal datatypes
(numerics probably too).

Not sure why you doing it that way

lblPreco.Text = reader.GetDecimal(1).ToString("c") should work...
Plus it's much faster ....

George.


"Paulo" <eris_paulo@xxxxxxxxxxxx> wrote in message
news:eGdCNestIHA.2064@xxxxxxxxxxxxxxxxxxxxxxx
Hi, I need to show on a label the data coming from db and it must show a
currency... I'm using a SqlDataReader reader, but doesnt work...

lblPreco.Text = Eval(reader[1].ToString(), "{0:c}");

Can you help me ? Thanks!

VS 2005 asp.net C# 2.0







.



Relevant Pages

  • Formating currency on label
    ... I need to show on a label the data coming from db and it must show a ... currency... ... I'm using a SqlDataReader reader, but doesnt work... ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Formating currency on label
    ... After you did reader[1].ToString() it becomes string and you can not apply ... currency... ... I'm using a SqlDataReader reader, but doesnt work... ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: sorry .09 instead of .08
    ... >> BigDecimal will be slower though. ... If the values are all currency ... >> values, with only 2 numbers after the decimal point, ints are a good ... too lazy and wanted to keep the message short ...
    (comp.lang.java.help)
  • Re: Intel announces 64-bit extensions
    ... like 15 times slower or something. ... This is a new platform, ... directly for delphi 7 doesnt always apply when i write .net code. ... my delphi7 code ...
    (borland.public.delphi.non-technical)
  • Re: sorry .09 instead of .08
    ... > zero wrote: ... >> BigDecimal will be slower though. ... If the values are all currency ... > Using ints is full of traps. ...
    (comp.lang.java.help)