Last post Mar 24, 2017 03:07 AM by Zhi Lv - MSFT
Mar 23, 2017 05:37 AM|hkbeer|LINK
I need to display a table of of 2 columns, name and sales on my web site.
However for the name, there are sub-totals
South 1 | 200
South 2 | 300
North 1 etc
North 2 etc
We need to display subtotal for South, East, etc and also a grand total for all.
in fact the above is simplified. Real data has several layers and many sub-totals
I already have good sqldatasource & to display this table, I know can be displayed in Gridview, but I have to code all the subtotal which will be a nightmare.
I can modify the sqldatasource so it includes rows of sub-totals, but need to feed into the grid into the relevant row which is a lot of efforts.
Please help. Any easy control we can use for this purpose, hope ASP.ent can supply such control for future.
For now, any recommendations ?
any supplies from Google (js) ?
Or is there a easy way to display part of an Excel table which can be refreshed on page load ?
Mar 23, 2017 11:46 AM|paindaasp|LINK
Can you break the name column into 2 columns, and then GROUP BY the 2 columns and Rollup? For instance, make the columns name, recID, quantity. Then you could sub-total, and total with this:
WHEN GROUPING(name) = 0 AND
GROUPING(recID) = 1 THEN RTRIM(name) + ' Total'
WHEN GROUPING(name) = 1 AND
GROUPING(recID) = 1 THEN 'Grand Total'
ELSE name end) as [Name], IsNULL(CONVERT(VARCHAR(10),recID),'') AS recID, sum(quantity) as Quantity
GROUP BY name, recID with rollup
Mar 24, 2017 03:07 AM|Zhi Lv - MSFT|LINK
Serious Help needed.. table control with easy subtotals
I suggest you could refer to the following articles to display SubTotal and Grand Total in GridView.
If you want to use T_SQL to calculate the subtotal and grand total, please refer to this links: