lblPreco.Text = Eval(reader[1].ToString(), "{0:c}");
Can you help me ? Thanks!
VS 2005 asp.net C# 2.0
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_...@terra.com.br> wrote in message
news:eGdCNest...@TK2MSFTNGP05.phx.gbl...
lblPreco.Text = string.Format("{0:c}", reader[1]);
Thank you very much!
"George Ter-Saakov" <gt-...@cardone.com> escreveu na mensagem
news:%23s6fLvs...@TK2MSFTNGP04.phx.gbl...
You should always pick the granular "get".
.GetString()
.GetDateTime
.GetInt32()
etc, etc.
Instead of .GetValue() ... or how you're (mis) using the ToString().
"George Ter-Saakov" <gt-...@cardone.com> wrote in message
news:%23s6fLvs...@TK2MSFTNGP04.phx.gbl...
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_...@terra.com.br> wrote in message
news:OKiqRxst...@TK2MSFTNGP04.phx.gbl...