473,388 Members | 1,213 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,388 software developers and data experts.

Totaling a column in Datgrid

Hi,
I would like to know if there is a way to print 'Sum' of all the
values of one of the columns in a datagrid in an ASP.net application
using vb.net. The Sum should be displayed all the way at the end below
the column values.

Like:
___________________________
Column1 Column2 Column3
___________________________
XX
YY
ZZ
--
SUM AA
--
___________________________
Nov 18 '05 #1
2 1232
one way to do this would be to forget the datagrid, but rather look at the
source...
if the source is a table, for example, you could easily enumerate through
the rows at that column, and tally up the value, then create a new row which
has a column for that total.
if the source isn't a table, convert it to one and make the table the data
source.

hope that helps.
Dan.

"Atif Jalal" <ma***@hotmail.com> wrote in message
news:b7**************************@posting.google.c om...
Hi,
I would like to know if there is a way to print 'Sum' of all the
values of one of the columns in a datagrid in an ASP.net application
using vb.net. The Sum should be displayed all the way at the end below
the column values.

Like:
___________________________
Column1 Column2 Column3
___________________________
XX
YY
ZZ
--
SUM AA
--
___________________________
Nov 18 '05 #2
One approach is to insert the subtotal into the footer row of the datagrid
in the itemdatabound routine.

if(e.itemtype == listitemtype.footer)
string strCol = columname;
e.item.cells[0].Columnspan = 2;
e.item.cells[0].Text = "Sum";
e.item.cells[0].BackColor= Color.LimeGreen;
e.item.cells[1].Text =
ds.Tables[0].Compute("Sum(["+strCol+"])",String.Empty));

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Atif Jalal" <ma***@hotmail.com> wrote in message
news:b7**************************@posting.google.c om...
Hi,
I would like to know if there is a way to print 'Sum' of all the
values of one of the columns in a datagrid in an ASP.net application
using vb.net. The Sum should be displayed all the way at the end below
the column values.

Like:
___________________________
Column1 Column2 Column3
___________________________
XX
YY
ZZ
--
SUM AA
--
___________________________

Nov 18 '05 #3

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

Similar topics

1
by: amber | last post by:
Hello, Why, when I right-align a column in a datgrid, do the headers cut off on the right? I can't figure out how to fix this... Can I put some type of buffer? I'm using te visual editor to...
5
by: nimdez | last post by:
Hi, I am working on an existing code base in which a lot of data displayed to the user is formatted in tables. Most tables are printed row-by-row using printf() with "%s" print conversion...
1
by: Dmitry V. Markin | last post by:
Good day! Here is my problem: I need to have a radiobutton column in my DataGrid for a representation of a bool column, where only row can be checked at one time(only one value in bool column...
19
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to...
3
by: Mike Fellows | last post by:
Im trying to set the column width of individual datgrid columns I can set the column widths of all the columns at once using Me.DataGrid1.PreferredColumnWidth = 100 But I am unable to set the...
2
by: ricky | last post by:
Hello, If anyone could help me with this I would highly appreciate it. I've tried everything and nothing works. What I am trying to do is so damn basic and it's just frustrating that it seems...
4
by: NormAmst | last post by:
I have a list of CPU processing times and job durations for an entire department at work. There are 3 classifications I am maintaining. CPU time during peak hours , CPU time during non peak hours...
2
by: sukitmw | last post by:
Hi, I'm trying to sum each column and each row of a datagrid and put the totals of columns at the bottom of each column and totals of row at the last empty column. How do I do this? I found...
2
by: grinder332518 | last post by:
In my report, I am populating a column with values computed by different means. Eg Rows 1 to 8 : column contents are (fieldA + fieldB) Row 9 : column...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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:
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.