开发者

Nested Gridview with subtotal/grandtotal

I'm using C# .net 2.0. My code behind dynamically generates a SQL statement that would return something like this in a dataset.

Name | Yes | No | NoReply | Group
Jo开发者_开发技巧hn |  1  |    |         |  A
Bob  |     |  1 |         |  A
Lee  |  1  |    |         |  B
Harry|     |    |      1  |  C
Liz  |     |  1 |         |  B

Currently, I bind the data to a GridView to display the result on a page. I'd like to break them up into group and have a subtotal and grandtotal at the bottom of each group. For example:

Group A:

Name | Yes | No | NoReply
John    1
Bob           1           
--------------------------
Subtotal 1    1     0  

Group B:

Name | Yes | No | NoReply
Lee     1                
Liz           1          
--------------------------
Subtotal 1    1

Group C:

Name | Yes | No | NoReply
Harry               1                
--------------------------
Subtotal            1

Grandtotal: sums of yes/no/no reply columns.       

What's the best way to go about doing this?


The best way that I would suggest is to group the data in SQL as you mentioned above and then use a Repeater control to bind the resulting data.

Hope this Helps!!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜