Group By in Gridview

(Pierre Mareschal) #1


I would like to show a single gridview with several ‘sections’.

If your store sells apples, pears, and cherries, I’d like to get a single gridview with a top heading, and let’s say ‘subheadings’ for my fruits.

Sell lines would come under those subheadings:

[font="Courier New"]amount | unit price | total <-- Top heading

Apples <-- Sub heading

2 2 4

1 2 2

       Total Apple:    6        &lt;-- Ideal sub total

Cherries <-- Sub heading

2 1 2

3 1 3

       Total Apple:     5        &lt;-- Ideal sub total

       Grand Total:     11      &lt;-- Totals[/font]

Any idea on how to do it with gridviews?

I currently have 4 gridviews (Kartik’s), one per fruit with their subtotal, and an additional gridview with subtotals and grand totals (collected with a sql group by sequence).

Would there be a more elegant way to achieve this?

Thank you.


(Oligalma) #2