RE: subheaders with totals for each

Tech-Archive recommends: Fix windows errors by optimizing your registry



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_How_to_Display_Sum_Total_in_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/Server_Nested_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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.

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



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








.



Relevant Pages

  • RE: Need help for solution in ASP.NET with VB
    ... I think it is like a Master-Details data display page. ... Then, in the right cell, you can use a Gridview and DetailsView control to ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • RE: GridView overriding InitializePager
    ... As for the GridView control, the "InitializePager " method is called by the ... If you do want to display some infomration when the records count is not ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: GridView / DataGrid difference
    ... directly displayed on page through DataGrid or GridView's databound ... ASP.NET 2.0 GridView ... you can use a TemplateField to maually bind and display the column ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: subheaders with totals for each
    ... As for displaying sub total row, there does exists some article demonstrate ... How to Display Sum Total in the Footer of the GridView Control ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework.aspnet)
  • adding comma seperated values from a multi line file and displaying data
    ... together and display the sum. ... display those numbers on a single line. ... totals. ... Support,Plex 4 Support,CPM Support,No Support Required,Delivery ...
    (perl.beginners)