Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Rounded Numbers

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
GB
In a SQL table I have a field that is decimal datatype.

I have two rows with data and some amounts.

These amounts are recorded in the table as 55.53600 and 144.99600. Add these two numbers together and you get £200.53.

However, when I display the information on a .net page, the amounts seem to round up to £55.54 and £145.00 respectively. Which add them together and you get £200.54. So I am a penny out. It rounds the numbers up if displaying in a datagrid.

However if I want to display just the total spent in a datalist, then then it displays the raw data from the table - £200.53 not the £200.54 as shown in the datagrid.

How can this be. Is there are way I can round the datalist as well.

My code for the datalist to display the info is

Code:
 <asp:Label ID="OverallTotalSpentLabel" runat="server" 
                                    Text='<%# Eval("OverallTotalSpent", "{0:C}") %>' />

My code in the datagrid is:
Code:
asp:BoundField DataField="Order_Amount" HeaderText="Amount" 
                                    SortExpression="Order_Amount" dataformatstring="{0:c}" 
                                    HtmlEncode="False" >
                                <HeaderStyle Width="90px" HorizontalAlign="Right" />
                                <ItemStyle HorizontalAlign="Right" />
                                </asp:BoundField>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top