views:

921

answers:

2

I'm using the new ASP.Net ListView control to list database items that will be grouped together in sections based on one of their columns like so:

region1
    store1
    store2
    store3
region2
    store4
region3
    store5
    store6

Is this possible to do with the ListView's GroupItemTemplate? Every example I have seen uses a static number of items per group, which won't work for me. Am I misunderstanding the purpose of the GroupItem?

+2  A: 

I haven't used GroupItemCount, but I have taken this example written up by Matt Berseth titled Building a Grouping Grid with the ASP.NET 3.5 LinqDataSource and ListView Controls and have grouped items by a key just like you want.

It involves using an outer and inner ListView control. Works great, give it a try.

Otto
I was hoping the ListView could do this without nesting another control, but if not that's how I would accomplish this. Just trying to keep the design simple.
Adam Lassek
A: 

I tried using GroupItemCount programmatically but it didn't give me the expected results.

I followed Otto's suggestion and implemented an outer and inner ListView control. This seems to be the best available solution.

mathijsuitmegen