<p>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:</p>

<pre><code>region1
    store1
    store2
    store3
region2
    store4
region3
    store5
    store6
</code></pre>

<p>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?</p>

[{'answer_id': 12735, 'author': 'Otto', 'author_id': 519, 'author_profile': 'https://Stackoverflow.com/users/519', 'pm_score': 3, 'selected': True, 'text': '<p>I haven\'t used GroupItemCount, but I have taken this example written up by <a href="http://mattberseth.com/" rel="nofollow noreferrer">Matt Berseth</a> titled <a href="http://mattberseth.com/blog/2008/01/building_a_grouping_grid_with.html" rel="nofollow noreferrer">Building a Grouping Grid with the ASP.NET 3.5 LinqDataSource and ListView Controls</a> and have grouped items by a key just like you want.</p>\n\n<p>It involves using an outer and inner ListView control.  Works great, give it a try.</p>\n'}, {'answer_id': 1631731, 'author': 'mathijsuitmegen', 'author_id': 78939, 'author_profile': 'https://Stackoverflow.com/users/78939', 'pm_score': 0, 'selected': False, 'text': "<p>I tried using GroupItemCount programmatically but it didn't give me the expected results. </p>\n\n<p>I followed Otto's suggestion and implemented an outer and inner ListView control. This seems to be the best available solution.</p>\n"}, {'answer_id': 21299212, 'author': 'c0d3m0nk3y', 'author_id': 3226224, 'author_profile': 'https://Stackoverflow.com/users/3226224', 'pm_score': 2, 'selected': False, 'text': "<p>Make sure you're doing a DataBind <strong>AFTER</strong> setting the GroupItemCount property. I had the same problem and that's what I did to resolve it.</p>\n"}]
['https://Stackoverflow.com/questions/12657', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1249/']