format for decimal values

N

Nariban Barkan

Hi All,

I have a decimal value on the GridView BoundField which comes from sql
server and it seems on gridview like that;
2096.62
14899.01

I want to display that values like
2.096,62
14.899,01

Thanks for any help
 
P

Pavel Minaev

Hi All,

I have a decimal value on the GridView BoundField which comes from sql
server and it seems on gridview like that;
2096.62
14899.01

I want to display that values like
2.096,62
14.899,01

Thanks for any help

If you want to use locale-dependent group separator and decimal point,
then you need the "N" format specifier.
 
M

Mihai N.

I have a decimal value on the GridView BoundField which comes from sql
server and it seems on gridview like that;
2096.62
14899.01

I want to display that values like
2.096,62
14.899,01


Convert to a double with Parse (or TryParse), then use ToString("N")
(or ToString("N",culture) if you want a culture other than the current one)
 
N

Nariban Barkan

Thanks all..

and can i add a special tag or a custom currency mark after or before the
value on the BoundField column ?
 
P

Pavel Minaev

Thanks all..

and can i add a special tag or a custom currency mark after or before the
value on the BoundField column ?

Then you need custom number format such as "#,##0.00'tag'" (note the
single quotes around 'tag' - they will ensure it is treated as a
literal string).
That's for CellFormatting event, though. For CellParsing, which you'll
also need for full two-way data binding, you'll probably want to trim
the tag/mark with String.Substring first, and then run it through
Decimal.Parse.

In general, I'd recommend searching MSDN for "Custom Numeric Format
Strings". It has more detailed explanations of what you can do with
this, and how.
 
M

Mihai N.

Then you need custom number format such as "#,##0.00'tag'" (note the
single quotes around 'tag' - they will ensure it is treated as a
literal string).

Proper locale-aware formatting is done by setting
NumberFormatInfo.CurrencySymbol and using ToString("C", ...)
A currency format is not just a number format with currency attached to it
(even in US -123 migh be represented as (123) when it's about financial
stuff)
 
P

Pavel Minaev

Proper locale-aware formatting is done by setting
NumberFormatInfo.CurrencySymbol and using ToString("C", ...)
A currency format is not just a number format with currency attached to it
(even in US -123 migh be represented as (123) when it's about financial
stuff)

That's assuming the original question was about locale-specific
currency formatting. However, the request was about "special tag or a
custom currency mark" - which, as I understand it, assumes that it is
not locale-dependent (and, indeed, may not be a currency sign at all,
merely something similar).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top