Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

datatable don't show the formatted value

Posted on 2010-01-13
8
Medium Priority
?
373 Views
Last Modified: 2012-05-08
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
0
Comment
Question by:ANAT2403
  • 4
  • 4
8 Comments
 

Author Comment

by:ANAT2403
ID: 26301933
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
 

Author Comment

by:ANAT2403
ID: 26302474
No body answer my qusetion??????????
I am expecting some treatment .................
thankyou
Anat
0
 
LVL 10

Expert Comment

by:codingbeaver
ID: 26309231
Do you want to keep the format in DataTable?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 10

Expert Comment

by:codingbeaver
ID: 26309259
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
 

Author Comment

by:ANAT2403
ID: 26311533
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
 
LVL 10

Expert Comment

by:codingbeaver
ID: 26314205
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
 

Author Comment

by:ANAT2403
ID: 26320908
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
 
LVL 10

Accepted Solution

by:
codingbeaver earned 2000 total points
ID: 26323339
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question