Re: Formating currency on label
- From: "George Ter-Saakov" <gt-nsp@xxxxxxxxxxx>
- Date: Thu, 15 May 2008 17:24:07 -0400
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
.
- References:
- Formating currency on label
- From: Paulo
- Re: Formating currency on label
- From: George Ter-Saakov
- Re: Formating currency on label
- From: Paulo
- Formating currency on label
- Prev by Date: Re: automatic screen capture
- Next by Date: Re: Remotely managing Access2K
- Previous by thread: Re: Formating currency on label
- Next by thread: Re: Formating currency on label
- Index(es):
Relevant Pages
|