Gridview SubHeadings

P

placebo137

Hi I have a sql query that Groups the data like so:

YEAR WHS

Here's the query

SELECT TOP 100 PERCENT YEAR([mydate]) AS Year, [whs], SUM([Sales])
AS Sales
FROM dbo.[SalesTable]
GROUP BY YEAR([myDate]), [whs]
ORDER BY YEAR([myDate]) DESC, [WHS]

So I get the columns

YEAR/WHS/SALES in my Gridview. The data looks something like this
2006/1/2000
2006/2/5488
2006/4/9000
2005/1/8000
2005/2/6754
2005/4/2390

How can I use a Gridview to add a heading each time the year changes?
Also Add a subtotal each time the year changes. I can add the totals
using RowDataBound - but it only seems like I can add up the Grand
Total in the

Here's the format I would like:

"2006 Sales"
1 2000
2 5488
4 9000
Total Sales for 2006 = $$$$

"2005 Sales"
1 8000
2 6754
4 2390
Total Sales for 2005 = $$$$
Grand Total (in footer)

This was really easy to do in ASP using Tables, but is there a similar
way either by using a Gridview or some other control to do this? I'd
like to convert my asp over, but when using gridview's it seems it
lacks the functionality to Add Subtotal rows. Any help or advice would
be appreciated. Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top