?
Solved

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

Posted on 2005-03-11
7
Medium Priority
?
375 Views
Last Modified: 2010-05-18
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
Comment
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
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 18

Expert Comment

by:testn
ID: 13522161
web or windows form?
0
 

Author Comment

by:patrickmulcahy
ID: 13522173
web form
0
 
LVL 18

Expert Comment

by:testn
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Accepted Solution

by:
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

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

Author Comment

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

Expert Comment

by:dungla
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Najam
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

752 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