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

Totalling DataGrid rows

I have a DataGrid bound to a DataTable and I'd like to have one row of totals.

I was hoping that I can have a row on the bottom of the DataGrid's results
which will always be visible (no matter how you scroll and no matter how you
filter the table) which adds up values in particular columns. Is it possible
to do this?

If not, what's the smartest way to handle this?

Should I create a second table which can somehow use the sum( ) functions to
total up the rows of another table? Then this table I guess would have to be
shown in a separate DataGrid under the one displaying the results
Nov 16 '05 #1
8 2030
MrNobody,

The DataGrid as it exists doesn't handle this. There might be some
third party grids that handle this though.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"MrNobody" <Mr******@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com...
I have a DataGrid bound to a DataTable and I'd like to have one row of
totals.

I was hoping that I can have a row on the bottom of the DataGrid's results
which will always be visible (no matter how you scroll and no matter how
you
filter the table) which adds up values in particular columns. Is it
possible
to do this?

If not, what's the smartest way to handle this?

Should I create a second table which can somehow use the sum( ) functions
to
total up the rows of another table? Then this table I guess would have to
be
shown in a separate DataGrid under the one displaying the results

Nov 16 '05 #2
MrNobody,

The DataGrid as it exists doesn't handle this. There might be some
third party grids that handle this though.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"MrNobody" <Mr******@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com...
I have a DataGrid bound to a DataTable and I'd like to have one row of
totals.

I was hoping that I can have a row on the bottom of the DataGrid's results
which will always be visible (no matter how you scroll and no matter how
you
filter the table) which adds up values in particular columns. Is it
possible
to do this?

If not, what's the smartest way to handle this?

Should I create a second table which can somehow use the sum( ) functions
to
total up the rows of another table? Then this table I guess would have to
be
shown in a separate DataGrid under the one displaying the results

Nov 16 '05 #3
MrNobody,

I should have been more specific. It's not possible if you want it in
one grid with the DataGrid.

The best way that you could do it would to do as you suggested, and have
a second data grid, where you have it bound to a second table which has the
sum of the values in the first table. You could create a relation (where
the sum table is related to all the fields in the other table), and then sum
up on the parent fields (you could create a column with an Expression
property set to this).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"MrNobody" <Mr******@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com...
I have a DataGrid bound to a DataTable and I'd like to have one row of
totals.

I was hoping that I can have a row on the bottom of the DataGrid's results
which will always be visible (no matter how you scroll and no matter how
you
filter the table) which adds up values in particular columns. Is it
possible
to do this?

If not, what's the smartest way to handle this?

Should I create a second table which can somehow use the sum( ) functions
to
total up the rows of another table? Then this table I guess would have to
be
shown in a separate DataGrid under the one displaying the results

Nov 16 '05 #4
MrNobody,

I should have been more specific. It's not possible if you want it in
one grid with the DataGrid.

The best way that you could do it would to do as you suggested, and have
a second data grid, where you have it bound to a second table which has the
sum of the values in the first table. You could create a relation (where
the sum table is related to all the fields in the other table), and then sum
up on the parent fields (you could create a column with an Expression
property set to this).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"MrNobody" <Mr******@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com...
I have a DataGrid bound to a DataTable and I'd like to have one row of
totals.

I was hoping that I can have a row on the bottom of the DataGrid's results
which will always be visible (no matter how you scroll and no matter how
you
filter the table) which adds up values in particular columns. Is it
possible
to do this?

If not, what's the smartest way to handle this?

Should I create a second table which can somehow use the sum( ) functions
to
total up the rows of another table? Then this table I guess would have to
be
shown in a separate DataGrid under the one displaying the results

Nov 16 '05 #5
Thanks again Nicholas,

Now if I wanted to use the Expression property on the second table to sum
the values in the first table, does that require that a DataRelation is
created between the two?
Nov 16 '05 #6
Thanks again Nicholas,

Now if I wanted to use the Expression property on the second table to sum
the values in the first table, does that require that a DataRelation is
created between the two?
Nov 16 '05 #7
MrNobody,

You have one of two choices. The first would be to actually append the
column to the original data table (or a copy of it) and have the expression
just be the sum of the field.

The other is to create a relation between the table and another table
which has one row. Basically, you have to add a column where the values are
all one value, and then set the column in the relation in the parent table
(the sum table here) to have the same value. Then you can set the
expression property to be the sum of the field in the child table (which
would be all the rows).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"MrNobody" <Mr******@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...
Thanks again Nicholas,

Now if I wanted to use the Expression property on the second table to sum
the values in the first table, does that require that a DataRelation is
created between the two?

Nov 16 '05 #8
MrNobody,

You have one of two choices. The first would be to actually append the
column to the original data table (or a copy of it) and have the expression
just be the sum of the field.

The other is to create a relation between the table and another table
which has one row. Basically, you have to add a column where the values are
all one value, and then set the column in the relation in the parent table
(the sum table here) to have the same value. Then you can set the
expression property to be the sum of the field in the child table (which
would be all the rows).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"MrNobody" <Mr******@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...
Thanks again Nicholas,

Now if I wanted to use the Expression property on the second table to sum
the values in the first table, does that require that a DataRelation is
created between the two?

Nov 16 '05 #9

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

Similar topics

1
by: Soul | last post by:
*** I am not sure this question belong to *.languages.csharp or *.framework.windowsdorms.databinding, so I post to both *** Hi, Currently I have a DataGrid which bind to a DataSet. One of...
5
by: BBFrost | last post by:
Win2000 ..Net 1.1 SP1 c# using Visual Studio Ok, I'm currently in a "knock down - drag out" tussle with the .Net 1.1 datagrid. I've come to realize that a 'block' of rows highlighted within...
0
by: MrNobody | last post by:
I have a DataGrid bound to a DataTable and I'd like to have one row of totals. I was hoping that I can have a row on the bottom of the DataGrid's results which will always be visible (no matter...
4
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. ...
4
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
5
by: Genojoe | last post by:
I am using code from Help with two exceptions. (1) I increased the number of sample rows from 3 to 20, and (2) I anchored the datagrid to bottom of form so that I can change the size of the grid by...
4
by: Jan Nielsen | last post by:
Hi all I'm a former Access developer who would like to implement a many-to-many relation in about the same way you do in Access: With a subform and a combo box. Is it possible to use a...
0
by: rn5a | last post by:
All the rows in a DataGrid are accompanied by a CheckBox. When a user checks the rows & clicks a Button, the checked rows get deleted. For e.g. assume that the DataGrid displays 10 rows. A user...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.