datatable don't show the formatted value

In ASP.NET 1.1 with C# I have a datatable.
one of the columns is Decimal.
I put in this cell a value which I collected
for example I got the value    26423874
I format this value to a string value and get the value  26,423,874.00
when I put this value in the datatable I get 26423874
Why is that?

part of the code:

DataTable dtableShow = new DataTable();
DataRow row = null;
decimal sumTotalBalanceDec = 0;
dtableShow ("totalBalance",typeof(Decimal));
row = dtableShow.NewRow();
object sumTotalBalance =  dtcollect.Compute("SUM(TotalBalance)",filter);
//  sumTotalBalance  = 26423874
sumTotalBalanceDec = Convert.ToDecimal(sumTotalBalance);
string titleImg = sumTotalBalanceDec.ToString("#,###0.00");
//  titleImg  = 26,423,874.00
row["totalBalance"] = titleImg;  //  = 26423874
ANAT2403Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ANAT2403Author Commented:
sorry, I had a mistake in one line in the kod:
dtableShow ("totalBalance",typeof(Decimal));
should be
dtableShow .Columns.Add("totalBalance",typeof(Decimal));
Anat
0
ANAT2403Author Commented:
No body answer my qusetion??????????
I am expecting some treatment .................
thankyou
Anat
0
codingbeaverCommented:
Do you want to keep the format in DataTable?
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

codingbeaverCommented:
FYI, if after certain hours there is still nobody answering your question, the EE system will automatically send out an alert to some designated experts asking them to attend to your question.

You may also know that experts answering questions here are volunteers.
0
ANAT2403Author Commented:
Hi codingbeaver
(Sorry I was a bit pressed and I needed a solution quickly, but I managed.)
yes I do want to keep the format in datatable and then I want to use the compute.
I did something now that solved my problems but still I have qustion.
In order to see the format, I canceled  the type of the column from decimal, and I guess now it is string.
Now I can see the format cell but I can't use the compute because it is not a numeric cell so I used
for each....
Is it possible to use compute on a non numeric column?
Thankyou
Anat
0
codingbeaverCommented:
I don't thnk so, and I am open for correction.

If I were you, I would like to keep the data type as numeric in database, because I could format it anyway I want in the future. But for string with format, take your case as example, 26,423,874.00, when you want to convert it to numeric, you will first have to remove the "," in the string, then you can parse it to a numeric value. Can I ask why you need to store the formatted string in your database instead of numeric?
0
ANAT2403Author Commented:
Hi
I don't keep any of this inormation in my database
I get the information from an xml file
(by the way I am force to work with dot net 1.1)
I trasfer it to a collection in a first datatable
then I prepare a second formatted datatable that in the end I bind to a datagrid.
I wanted to summarize the values in the second datatable.
I already solved my problem by using the foreach command but I wanted to know
on what types I can use the compute function
thankyou
Anat
0
codingbeaverCommented:
That's good you got it solved.

I believe you have to have numeric data type to use compute, and I am open for correction.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.