473,386 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Convert formatted string to string?

Hi, All

I have a datagrid with TemplateColumn as following. Notice the "{0:c}"
format the price as $8.90 for 8.90 and ($7.8) for -7.8

<ItemTemplate>
<asp:Label id=lblPrice runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.price","{0:c}") %>'>
</asp:Label>
</ItemTemplate>

on the backend C# code:

I need to get the price and do some calculation

decimal decPrice =
decimal.Parse(lblPrice.Text,System.Globalization.N umberStyles.AllowCurrencySymbol);

It does not work.

How should I do to get the original numeric without the formatting?

Thanks a lot

Apr 11 '06 #1
3 1128
On 11 Apr 2006 13:02:31 -0700, rockdale wrote:
I need to get the price and do some calculation

decimal decPrice =
decimal.Parse(lblPrice.Text,System.Globalization.N umberStyles.AllowCurrencySymbol);

It does not work.


While you can make this solution work, wouldn't it be much easier just to
use the data from the dataset?
Apr 11 '06 #2
Strip out the '$' character first.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"rockdale" <ro************@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
Hi, All

I have a datagrid with TemplateColumn as following. Notice the "{0:c}"
format the price as $8.90 for 8.90 and ($7.8) for -7.8

<ItemTemplate>
<asp:Label id=lblPrice runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.price","{0:c}") %>'>
</asp:Label>
</ItemTemplate>

on the backend C# code:

I need to get the price and do some calculation

decimal decPrice =
decimal.Parse(lblPrice.Text,System.Globalization.N umberStyles.AllowCurrencySymbol);

It does not work.

How should I do to get the original numeric without the formatting?

Thanks a lot

Apr 11 '06 #3
Thanks for the replies.
I am using datatable but DataSet

private void RegisteredTapeDetailDataBinding(int pStoreKey, int
pFiscalKey)
{
SqlStorage ss = new SqlStorage();
dgridResult.DataSource = ss.GetPriceDataTable(pStoreKey).DefaultView;
dgridResult.DataBind();
}

I do not think I can use the data in a datatable, am I right?
Thanks

Apr 12 '06 #4

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

Similar topics

7
by: querypk | last post by:
how do I convert b is a string b = '(1,2,3,4)' to b = (1,2,3,4)
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
2
by: megala | last post by:
Hi How to convert a string "11022005" to a specific date format-02/11/2005
12
by: DC Gringo | last post by:
How can I convert this pubLatest to a date with format "m/d/yyyy"? Dim pubLatest As New Date pubLatest = Me.SqlSelectCommand1.Parameters("@pubLatest").Value -- _____ DC G
2
by: KB | last post by:
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...
5
by: Mika M | last post by:
Hi! I've made little code to convert string into hex string... Public ReadOnly Property ToHexString(ByVal text As String) As String Get Dim arrBytes As Integer() = CharsToBytes(text) Dim sb...
5
by: rsanan | last post by:
How do I convert a datetime from en-GB to en-US format here is my code - (not working for the clients outside of US) /*******************CODE*****************/ System.Globalization.CultureInfo...
3
by: iwdu15 | last post by:
hi, how can i convert rtf encoding to HTML? i looked at previous posts and i cant seem to find the HTTPUtility in vbexpress 2005. Is it not there, and is there another way? thanks -- -iwdu15
4
by: csgraham74 | last post by:
Hi, Ive posted on this previously but had no response. Basically i need to build some html using a rich text editor. Then i want to actually create an html document from this and save it to my...
2
by: phil.swenson | last post by:
I'm using Prototype.js and would like to convert the contents of an HTML table to JSON. Converting to an array first is fine too. Any thoughts on this? I haven't seen anyone do anything this.......
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.