Hi guys,
In my DataGrid I have a column that displays decimal values as currency ( I
set the Data Formatting expression of that column to {0:C}). So the actual
string displayed in the grid looks like $2,295.99.
For each row I need to do some additional calculations based on this value,
so I need to convert it back to decimal type. But I cannot find a way to get
rid of the currency formatting and revert the value back to decimal. I tried
the following:
Convert.ToDecimal( e.Item.Cells[ColValue].Text ); // Input string was
not in a correct format
String.Format( "{0:N}", e.Item.Cells[ColValue].Text) // returns $2,295.99
String.Format( "{0:D}", e.Item.Cells[ColValue].Text) // returns $2,295.99
String.Format( "{0:G}", e.Item.Cells[ColValue].Text) // returns $2,295.99
String.Format( "{0:R}", e.Item.Cells[ColValue].Text) // returns $2,295.99
Anyone knows how to solve this.
Cheers
Kevin 2 10570
Kevin,
Just remove the $ and the , like so
e.Item.Cells[ColValue].Text.Replace("$","").Replace(",",""). The replace
just replaces them with nothing, essentially removing them from the string.
Hope this helps,
Mark FItzpatrick
Microsoft MVP - FrontPage
"KB" <a@b.com> wrote in message
news:eo******************@TK2MSFTNGP15.phx.gbl... Hi guys,
In my DataGrid I have a column that displays decimal values as currency ( I set the Data Formatting expression of that column to {0:C}). So the actual string displayed in the grid looks like $2,295.99. For each row I need to do some additional calculations based on this value, so I need to convert it back to decimal type. But I cannot find a way to get rid of the currency formatting and revert the value back to decimal. I tried the following:
Convert.ToDecimal( e.Item.Cells[ColValue].Text ); // Input string was not in a correct format String.Format( "{0:N}", e.Item.Cells[ColValue].Text) // returns $2,295.99 String.Format( "{0:D}", e.Item.Cells[ColValue].Text) // returns $2,295.99 String.Format( "{0:G}", e.Item.Cells[ColValue].Text) // returns $2,295.99 String.Format( "{0:R}", e.Item.Cells[ColValue].Text) // returns $2,295.99
Anyone knows how to solve this.
Cheers
Kevin
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: techy techno |
last post by:
hii Experts..!!
I need someone to tell me where I can get a Currency Converter like
http://cconv.textor.com
please can someone tell me where I can get it
I need it for free + I dont need...
|
by: Dalan |
last post by:
This should not be an issue, but it is. I'm sure that someone knows
what little piece of code is needed too persuade Access 97 to include
a currency format for labels (Avery, mailing type). Have...
|
by: Baybars |
last post by:
New to access, but to deja.com. Looked through many posts, but can not
find a good post for my problem (I believe there is, but my access
level didn't allow me to understand).
I have a table for...
|
by: news.shaw.net |
last post by:
I have a subform that contains a currency field.
If I tab my way to the field, everything works as desired, a number can
be entered, and when I leave the field it is rendered as a currency...
|
by: Vishal |
last post by:
Hello,
how can we convert a value from one currency to
another currency in vb.net? Is that possible? I dont want
to use any hardcoded value for the exchange rate. I wont
to get it online and do...
|
by: Adrian |
last post by:
Hi
I want to use the following declarations but vb dotnet keeps complaining
that currency can't be used because it private ?
I have tried it in a module and in the declaration pare same error!...
|
by: Chakravarthy |
last post by:
Given an XML stream as below, is there any possibility to convert the same
into any treditional class style with . (dots) as seperator of the nodes of
the xml file...
for instance
...
|
by: czi02 |
last post by:
Hi there;
Is there anybody out there knows how to design a function or data flow on how to convert a numerical currency valu (33,163.33) into words
33Million one hundred sixty three thousand...
|
by: vivek kushwaha |
last post by:
Hi guys,
I need codes to convert Currency into Words. e.g.
120,500 into "One Lac. Five hundred only."
in asp.net with vb.net 1.1.
Please if anybody know about it. Reply me.
Vivek.
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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,...
| |