Oct 06 2006

ASP.NET grouping repeater control

Posted by admin under Controls

If you download the attachment solution (available in part 7), you'll see that I have called this the "poormans group control". The goal with it was NOT to add grouping capabilities to the datagrid/gridview. Also the goal is NOT  to provide the perfect grouping solution - but instead my goal is to provide you with some knowledge on how you could implement grouping in your own solutions.

So first - it is NOT a grid extension. It is built around a simple repeater - and it's not even a control derived from repeater. It's just a class meant to work with a repeater setup in a certain way. It's your choice whether you want to create a fullfledged server control out of it - I just want this example to be as easy as possible:

Actually the solution might turn out to be good enough for you - and indeed I have used it pretty much as it is presented here in some of my own solutions - sometimes you just don't want/need all the advanced stuff the grid can provide, but just  a simple table - but with grouping capabilities of course.

Lets start by looking at the sample:

 

 

 

We are using northwind, and presenting some stuff from the [Orders] table. The groups plus/minus image allows for clicking:

and when clicking expanding/collapsing the client rows.  

In the example solution I have added the possibility to dynamically change the grouping column:

And of course you can select to not group at all. Now lets start by looking at some code.

Read part 2