Search code examples
asp.net.net-3.5listview

Can I create a ListView with dynamic GroupItemCount?


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?


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.