This documentation is archived and is not being maintained.

ListView.GroupItemCount Property

Gets or sets the number of items to display per group in a ListView control.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

public virtual int GroupItemCount { get; set; }
<asp:ListView GroupItemCount="Int32" />

Property Value

Type: System.Int32
The number of items to display per group in a ListView control. The default is 1, which indicates that the ListView control will display one item per group.


The GroupItemCount property is set to a value less than 1.

Use the GroupItemCount property to specify the number of items to be grouped together in the ListView control. (In other words, this specifies the number of items to display for each group of the control.) For each group, the ListView control renders the contents of the GroupTemplate template and replaces the item placeholder with the actual item content. It does this as many times as the number of items defined by the GroupItemCount property.

You can use GroupItemCount with the GroupTemplate template to create a tiled layout in the ListView control. In a tiled table layout, the items are repeated horizontally in a row. The numbers of times that an item is repeated is specified by the GroupItemCount property.

The following example shows how to create a tiled layout in the ListView control by using the GroupItemCount property. It also shows how to change this property programmatically.

<%@ Page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<script runat="server">

    protected void GroupItemCountList_SelectedIndexChanged(object sender, EventArgs e)
      // Changes the number of items displayed for each group.
      ContactsListView.GroupItemCount = 


<html xmlns="" >
  <head id="Head1" runat="server">
    <title>ListView GroupItemCount Example</title>
    <style type="text/css">
      body { font: 10pt Trebuchet MS; }        
    <form id="form1" runat="server">

      <h3>ListView GroupItemCount Example</h3>

      Number of columns:
      <asp:DropDownList ID="GroupItemCountList"
          <asp:ListItem Selected="True">2</asp:ListItem>
      <br />
      <br />      
      <hr />

      <asp:ListView ID="ContactsListView" 
          <table id="tblContacts" runat="server" cellspacing="0" cellpadding="2">
            <tr runat="server" id="groupPlaceholder" />
          <asp:DataPager runat="server" ID="ContactsDataPager" PageSize="24">
                ShowFirstPageButton="true" ShowLastPageButton="true"
                FirstPageText="|&lt;&lt; " LastPageText=" &gt;&gt;|"
                NextPageText=" &gt; " PreviousPageText=" &lt; " />
          <td align="center" style="width:10px" runat="server">
            <asp:Label ID="IDLabel" runat="Server" Text='<%#Eval("ContactID") %>' />
          <td style="width:70px" runat="server">
            <asp:Label ID="FirstNameLabel" runat="Server" Text='<%#Eval("FirstName") %>' />
          <td style="width:70px" runat="server">
            <asp:Label ID="LastNameLabel" runat="Server" Text='<%#Eval("LastName") %>' />
          <tr runat="server" id="ContactsRow" style="background-color: #FFFFFF">
            <td runat="server" id="itemPlaceholder" />
          <td runat="server" style="border-right: 1px solid #00C0C0">&nbsp;</td>

      <!-- This example uses Microsoft SQL Server and connects      -->
      <!-- to the AdventureWorks sample database. Use an ASP.NET    -->
      <!-- expression to retrieve the connection string value       -->
      <!-- from the Web.config file.                                -->
      <asp:SqlDataSource ID="ContactsDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
        SelectCommand="SELECT [ContactID], [FirstName], [LastName] FROM Person.Contact">


.NET Framework

Supported in: 4, 3.5

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.