Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

Make sure you're doing a DataBind AFTER setting the GroupItemCount property. I had the same problem and that's what I did to resolve it.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top