473,498 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

format for decimal values

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
Jun 27 '08 #1
8 1563
"Nariban Barkan" <So**********@s.comwrote in message
news:e9**************@TK2MSFTNGP06.phx.gbl...
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
<asp:BoundField DataField="MyField" DataFormatString="{0:#.##0,00}"
HtmlEncode="false" HeaderText="MyField" />
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #2
On Jun 9, 11:50 am, "Nariban Barkan" <SomeFunny...@s.comwrote:
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.
Jun 27 '08 #3
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)

--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Jun 27 '08 #4
Thanks all..

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


Jun 27 '08 #5
On Jun 9, 4:50*am, "Nariban Barkan" <SomeFunny...@s.comwrote:
Thanks all..

and can i add a special tag or a custom currency mark after or before the
value on the BoundField column ?
...or you can do format it in your sql server procedure... --for
example see :
http://www.siccolo.com/Articles/SQLS...-currency.html

I know that not everyone is fond of formatting on sql server side, but
it's just a suggestion...
... more at http://www.siccolo.com/articles.asp
Jun 27 '08 #6
On Jun 9, 12:50 pm, "Nariban Barkan" <SomeFunny...@s.comwrote:
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.
Jun 27 '08 #7
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)

--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Jun 27 '08 #8
On Jun 11, 10:18 am, "Mihai N." <nmihai_year_2...@yahoo.comwrote:
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)

--
Mihai Nita [Microsoft MVP, Visual C++]http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
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).
Jun 27 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
19215
by: stevek | last post by:
How do I format an integer. Add commas. 1234565 1,234,565 TIA
1
8800
by: Nick | last post by:
Well, the project I am working on has now come to a screeching halt! I have been developing a program that heavily utilizes ADO.NET record sets. To generate reports, I convert the recordset to XML,...
1
15461
by: Mike MacSween | last post by:
This looks like a bug to me. I have an expression on a report: =Format(Sum((**)*(/)),"0.00") Score is byte PercentOfGrade is double PropDegree is single ModuleCats is byte
1
7967
by: Terencetrent | last post by:
I am trying to format a query expression drawn from a dialog box as percent. The original statement to get the value for the query is as follows: New%markup: !! The dialog box looks the...
2
1488
by: Hers2keep | last post by:
I have the following control on a report: "Total " & & " " & & " -- " & Format$(Sum(),"Standard") I can't use the simple way because of the concatenated fields. How can I force no decimal...
7
5221
by: Sick | last post by:
My application populates a ListBox from a .TXT file. In the textfile there are prices with both dots as well as comma's for decimal indication. Example: 1234990; xg-tr-45; 1700,50; 0 2662666;...
5
2189
by: Robin Tucker | last post by:
My database has a column for numeric data items. How can I use this number in the "format" command, such that for, say precision 2, I get numbers like 2011.01 or 2387.00 and for 4 I would get...
2
12493
by: AMDRIT | last post by:
Hello Everyone, I would like to format the Display Members of a combobox's datasource. Is there a way to apply a format without subclassing the original datasource? For example, given a list of...
11
2229
by: RipperT | last post by:
Don't know if this group covers web apps, but here goes. In VS 2005, I am trying to get variables to hold thier values during postback from the server. I convert a text box's user-keyed value to an...
2
6967
by: hunslair | last post by:
This is a really basic question. I am taking a teach yourself beginners course on Access 2003 and have run into a road block on one practice. In a select query, I have created a simple calculation...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7004
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5464
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4915
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4593
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
657
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
292
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.