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

subheaders with totals for each

I'm using a gridview and I have it formatted using sub headings. now I need
to get totals for each sub heading. Is this possible?

example:

BMW (sub heading) 25,000
14,252
25,000
total: 64,252

Lexus 72,633
11,500
6500
total: 90,633

and so on, is this possible to do and if so can someone point me to a site
or code snippet? I already have the subheaders I just need to figure out how
to add the totals in there as well

Oct 16 '06 #1
3 5223
Hello Mike,

As for displaying sub total row, there does exists some article demonstrate
on adding sum total footer in GridView or datagrid:

#CodeSnip: How to Display Sum Total in the Footer of the GridView Control
http://aspalliance.com/782_CodeSnip_...n_the_Footer_o
f_the_GridView_Control

For your scenario, you're wantting to add a sum total for each sub group in
the GridView, I think it is certainly doable and will be much easier than
displaying the grouped sales total datas in your another thread :).

I'm wondering how are you displaying the sub group in the GridView
currently? Are you using nested Databound control (such as GridView nest
Gridview or Repeater nest GridView ...)? Would you also give me the table
structure of the datasource?

For such scenario, I would suggest you use nested databinding, e.g.

use a repeater to display each main record and in each repeater row, use a
nested GridView to display sub records. Thus, you can use the above article
to calculate and display sum total data in sub GridView's footer.

here are some web artcles introducing how to perform nested databinding in
ASP.NET

#Nested GridViews with Skins in ASP.NET
http://www.codeproject.com/useritems/SkinSample.asp

#Nesting Repeaters with Hierarchical Data and Server-Binding
http://www.codeproject.com/aspnet/Se..._Repeaters.asp

If you have anything unclear on this, please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.



Oct 17 '06 #2
Hi Steve,
This project and my other posting are for 2 different projects. I need
both of these actually to work.

for this one I have subheaders that has sales data and I need total for each
suber header then yeah a total in the footer for all as well.

I'm grouping the subheaders as such:
string salesMan
string preSales= " ";
int i = 0;
while (i <= dsSales.Tables[0].Rows.Count - 1)
{
salesMan= dsSales.Tables[0].Rows[i]["SalesMan"].ToString();
if (salesMan.ToString() != preSales)
{
preSales= salesMan
DataRow shRow = dsSales.Tables[0].NewRow();
shRow["ID"] = salesMan;
shRow["SalesType"] = " ";
dsSales.Tables[0].Rows.InsertAt(shRow, i);
i += 1;
}
i += 1;
}
grdSales.DataSource = dsSales;
grdSales.DataBind();

then in the gridview rowdatabound i'm doing this:
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[1].Text.Equals(" "))
{
e.Row.Cells[0].Attributes.Add("align", "Left");
e.Row.Cells[0].ColumnSpan = 2;
e.Row.Cells[0].Font.Bold = true;
e.Row.Cells.RemoveAt(1);
e.Row.BackColor = Color.LightBlue;
}

so with this how can i add totals for each subheader/group?
the other posting is still valid, there 2 different projects

"Steven Cheng[MSFT]" wrote:
Hello Mike,

As for displaying sub total row, there does exists some article demonstrate
on adding sum total footer in GridView or datagrid:

#CodeSnip: How to Display Sum Total in the Footer of the GridView Control
http://aspalliance.com/782_CodeSnip_...n_the_Footer_o
f_the_GridView_Control

For your scenario, you're wantting to add a sum total for each sub group in
the GridView, I think it is certainly doable and will be much easier than
displaying the grouped sales total datas in your another thread :).

I'm wondering how are you displaying the sub group in the GridView
currently? Are you using nested Databound control (such as GridView nest
Gridview or Repeater nest GridView ...)? Would you also give me the table
structure of the datasource?

For such scenario, I would suggest you use nested databinding, e.g.

use a repeater to display each main record and in each repeater row, use a
nested GridView to display sub records. Thus, you can use the above article
to calculate and display sum total data in sub GridView's footer.

here are some web artcles introducing how to perform nested databinding in
ASP.NET

#Nested GridViews with Skins in ASP.NET
http://www.codeproject.com/useritems/SkinSample.asp

#Nesting Repeaters with Hierarchical Data and Server-Binding
http://www.codeproject.com/aspnet/Se..._Repeaters.asp

If you have anything unclear on this, please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.



Oct 17 '06 #3
Hello Mike,

Thanks for your reply.

From your further description and the code snippet you provide, I can get
that you're manually modify the datatable's records and add those sub rows.
And in Gridview's RoeDataBound, you'll remove a certain table cell to
display the indent before each sub row, correct?

I think you can consider use nested databinding to display such main-sub
records(include calculating sum total footer data). Would you also post
the original TableStructure and sample data you will get from database
query? Thus, I can perform research against it and provide some more
detailed suggestion or code snippet.

Please feel free to let me know if you have any questions.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 18 '06 #4

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

Similar topics

2
by: Deano | last post by:
OK, I'm working on a solution to the following problem but there are other ways to skin a cat as they say... Here's the table (simplified); ID EmployeeName SalaryAcc 1 Brown ...
2
by: deko | last post by:
I have a number of queries that pull totals from different tables. How do I sum the different total values from each query to get a grand total? I tried using a Union query like this: SELECT...
4
by: New Guy | last post by:
I'm trying to work with a system that somebody else built and I am confounded by the following problem: There is a table of payments and a table of charges. Each client has charges and payments...
4
by: spammy | last post by:
Hi all, Is it possible to create subheaders in datagrids? Or rather to add a parent header row to an existing datagrid? Currently my DG looks like this: NAME | A - PART1 | A - PART2 | A -...
2
by: BerkshireGuy | last post by:
I have the following code: Dim strSQL As String Dim DB As DAO.Database Dim RS As DAO.Recordset Dim intNumOfPaid, intNumOfHypoed, intNumOfNotTaken, intNumOfDeclined, intNumOfWasted,...
5
by: igotyourdotnet | last post by:
I have a gridview were i'm using subheaders, but now I want to add totals for each 'subheader'. First, is that possible to do, and second, can someone point me to an example how this works? My...
3
by: =?Utf-8?B?Um9iZXJ0IENoYXBtYW4=?= | last post by:
Hi, Fairly easy to create one running total for a gridview but what if you have dozens of them? I have a gridview that allows bulk editing (all rows at once) and have it set up so that, on data...
3
by: jszczepankiewicz | last post by:
Witam, mam nastepujacy problem: XSLT 2.0, Hi, i've got following problem with xslt 2: my xml doc looks something linke: <manual>
2
by: Tom | last post by:
All: I have a report that lists quantities of stuff used over the course of a year and it is grouped on each month. In the group footer I want to insert the total for the month - easy stuff so...
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: 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
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...
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.