473,395 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

adding decimal values in a datagrid.- please help

Hi,
I'm populating a datagrid with values and adding one of the columns to get a total. It adds up correctly but rounds off the values.

For example if the total is 2.56789 it makes it three as a total and shows in the footer of the grid.
I wanna get exact 2.56789 to show.
I tried converting it to decimal but still it rounds it off.
Any help will be appreciated.


Expand|Select|Wrap|Line Numbers
  1. Sub ComputeSum(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
  2.  
  3.         If e.Item.ItemType = ListItemType.Item Or _
  4.               e.Item.ItemType = ListItemType.AlternatingItem Then
  5.  
  6.             Dim viewCount As Integer = _
  7.            DataBinder.Eval(e.Item.DataItem, "Cond_Rate")
  8.             viewCountSum += viewCount
  9.  
  10.         ElseIf e.Item.ItemType = ListItemType.Footer Then
  11.             e.Item.Cells(2).Text = "Total:  " & System.Convert.ToString(viewCountSum)
  12.         End If
  13.     End Sub
  14.  
Mar 1 '07 #1
1 1275
kenobewan
4,871 Expert 4TB
Try viewCountSum.ToString("d").
Mar 4 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Andrés Giraldo | last post by:
Hi! I'm showing decimal values in a datagrid, but the decimal point shown is the "," and the correct is the ".". The datagrid is filled with a dataset, the dataset is filled with a SQL Server...
6
by: Robert Schuldenfrei | last post by:
Dear NG, After being away from C# programming for a spell, I am trying my hand at what should be a simple task. I have been hitting my head against the wall this morning. I have a simple order...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
2
by: Piotr | last post by:
Hi I'm working with Datagrid containg decimal (editable) numbers. The user-entered numbers are read by decimal.Parse() method. However, Datagrid formats some decimals as "1", but some as (eg)...
3
by: AMD Desktop | last post by:
Hi, I need to add a header to a datagrid. This is the code I am trying to use: Dim dgStaffingReport As New DataGrid Dim dgitem As New DataGridItem(0, 0, ListItemType.Header) Dim mycell...
1
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
5
by: Aaron Ackerman | last post by:
I have a bound combobox the appears on a cell within the column of my bound grid when the user clicks on a cell n(In my vb.net WinForm app). I am trying to allow the adding of an item to that bound...
5
by: =?Utf-8?B?S3VuYWwgUGF0ZWw=?= | last post by:
I have a DataTable with Column DataType as Double I just want to show data in C# datagrid with two decimal places which property do I set for DataColum of DataTable and How? Thanks
10
by: Guillermo_Lopez | last post by:
Hello All, I am using VBA in access to perform some calculations. There is a particular sumation that is wrong (barely). this code is withing a loop. TDist = TDist + TempDist Both TDist...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.