Solved

Make it so there always two digits after the decimal point for displaying a "total" column

Posted on 2005-03-11
Medium Priority
375 Views
I have an access database I'm accessing using oledb in C#. I have two fields (quantity and unit price) that I am multiplying to display in a datagrid as "total." The problem is that when the total ends up being a number like \$3.20, it gets displayed as 3.2

So, how can I make sure that there are always 2 digits after the decimal point? Does the answer lie in the sql itself, or is there c# code that will do this?
0
Question by:patrickmulcahy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3
• 3

LVL 18

Expert Comment

ID: 13522161
web or windows form?
0

Author Comment

ID: 13522173
web form
0

LVL 18

Expert Comment

ID: 13522317
when you put dataformat in there, make sure that you put the format string to be {0:N2} or {0:#,##0.00}
0

LVL 18

Accepted Solution

testn earned 1000 total points
ID: 13522319
like this...
http://aspnet.4guysfromrolla.com/articles/041702-1.2.aspx
<asp:BoundColumn DataField="yourfield" DataFormatString="{0:#,###}" ...... />
0

Author Comment

ID: 13522366
What do you mean, In the actual database? How about using sql?
0

Author Comment

ID: 13522375
Okay, just saw the link. I'll try this on Monday. Thanks. Time to go home.
0

LVL 13

Expert Comment

ID: 13522518
You can make change to your sql, in UnitPrice and Quantity, change sclae up to 2. For example

Quantity - decimal - length = 9,
Look at below for Column tab:

Precision: 18
Scale: 2 (allow 2 digit after point)
0

Featured Post

Question has a verified solution.

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

Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month11 days, 20 hours left to enroll