473,406 Members | 2,217 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,406 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 2031
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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:
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
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
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.