Convert formatted string to string?

R

rockdale

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.NumberStyles.AllowCurrencySymbol);

It does not work.

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



Thanks a lot
 
E

Erik Funkenbusch

I need to get the price and do some calculation

decimal decPrice =
decimal.Parse(lblPrice.Text,System.Globalization.NumberStyles.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?
 
K

Kevin Spencer

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.
 
R

rockdale

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
 

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,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top