473,405 Members | 2,287 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,405 software developers and data experts.

DataGrid, Footer, and Total

Hi.

I am trying to calculate the total of a column in a datagrid. The amounts
display fine on the grid, but the value of each cell is "" when
DataGrid1_ItemDataBound is called. A funny thing is that a date column after
the amount column has a valid value for each cell of the date column. Please
help.

Here is my code:

private void DoTotal(string sAmount)
{
try
{
m_dTotal += Double.Parse(sAmount);
}
catch
{
}
}

public void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
DoTotal(e.Item.Cells[5].Text);
//e.Item.Cells[5].Text = string.Format("{0:C}",
Convert.ToDouble(e.Item.Cells[5].Text));
}
else if(e.Item.ItemType == ListItemType.Footer)
{
e.Item.Cells[4].Text="Total";
e.Item.Cells[5].Text = string.Format("{0:C}", m_dTotal);
}
}
--
Be Cool!
Jul 21 '05 #1
1 1487
Jack,

Are you sure you cannot use the datacolumn.compute in one or the other way?

http://msdn.microsoft.com/library/de...mputetopic.asp

Just as idea?

Cor
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jon | last post by:
Hi, Working on a shopping cart app. I'm using a datagrid on the shopping cart page with boundcolumns to display Product name, cost, quantity etc - that all works fine. However I want to add a row...
9
by: Justin | last post by:
I am trying to figure out how to display the sum total of a numeric column in the footer of a datagrid. I have tried putting a label control in the footer of a column but for some reason when I try...
3
by: Mau | last post by:
I have a question: I have a datagrid with paging (4 elements for page), header and footer I set a fixed height: 600px So the situation is (in a page with 5 elements) 6 rows (header + 4...
4
by: JJ | last post by:
Hi, I am using a datagrid to display employee time sheets and need a running total for datagrid. So I am wondering since I am displaying totals in footer, should I use maybe a new datalist or...
1
by: .Net Sports | last post by:
I'm trying to display the total of a list of numbers in a datagrid. The numbers (dollaramount in sales) will be part of a dataset according to the date queried. I will display the total in the...
1
by: thejackofall | last post by:
Hi. I am trying to calculate the total of a column in a datagrid. The amounts display fine on the grid, but the value of each cell is "" when DataGrid1_ItemDataBound is called. A funny thing...
2
by: NuB | last post by:
I have a datagrid that I need to allow the user to page and sort as well. first, paging I need to show the pages in the footer of the grid like this Page 1, 2, 3, 4, 5, .etc and then in the...
1
by: .Net Sports | last post by:
the below itemdatabound function works , displays all the grand totals in the footer control of the datagrid: private void dglvboard_ItemDataBound(object sender,...
1
by: methexandude | last post by:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.