This documentation is archived and is not being maintained.

ListView.GroupSeparatorTemplate Property

Gets or sets the user-defined content for the separator between groups in a ListView control.

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

public virtual ITemplate GroupSeparatorTemplate { get; set; }

Property Value

Type: System.Web.UI.ITemplate
An object that contains the custom content for the group separator. The default is null, which indicates that this property is not set.

The separator enables you to put an element that has custom content between each group. The ListView control then alternately renders the GroupTemplate content and the GroupSeparatorTemplate content. The GroupTemplate content is always rendered last.

Make sure that you define the content for the whole row in the GroupSeparatorTemplate template, because the ListView control renders the GroupSeparatorTemplate content inside the LayoutTemplate template. For example, the groups in the ListView control might be created by using a table row (tr) element. If the GroupItemCount property is set to 3, the colspan attribute must be set to 3 in the GroupSeparatorTemplate template.

To specify a template declaratively for the separator, add a GroupSeparatorTemplate element inside the ListView control. You can then add the contents of the template to the GroupSeparatorTemplate element.

The following example shows how to create a group separator in the ListView control by using the GroupSeparatorTemplate property.

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

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

<html xmlns="" >
  <head id="Head1" runat="server">
    <title>ListView Tiled Layout Example</title>
    <style type="text/css">        
          border-top:solid 1px #9dbbcc;
          border-bottom:solid 1px #9dbbcc;
        .separator { border-right: 1px solid #ccc; }
    <form id="form1" runat="server">

      <h3>ListView Tiled Layout Example</h3>

      <asp:ListView ID="ProductsListView" 
          <table cellpadding="2" width="640px" runat="server" id="tblProducts">
            <tr runat="server" class="header">
              <th runat="server" colspan="3">PRODUCTS LIST</th>
            <tr runat="server" id="groupPlaceholder" />
          <tr runat="server" id="ProductsRow">
            <td runat="server" id="itemPlaceholder" />
          <tr runat="server">
            <td colspan="3"><hr /></td>
          <td align="center" style="width:300px" runat="server">
            <asp:HyperLink ID="ProductLink" runat="server" 
               Text='<%# Eval("Name") %>' 
             NavigateUrl='<%# "ProductDetails.aspx?productID=" + Eval("ProductID") %>' /><br />
            <asp:Image ID="ProductImage" runat="server"
               ImageUrl='<%# "~/images/thumbnails/" + Eval("ThumbnailPhotoFileName") %>' /><br />
            <asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("ListPrice", "{0:c}")%>' /><br />
          <td class="separator" runat="server">&nbsp;</td>
      <br />

      <asp:DataPager runat="server" ID="ProductsDataPager" 
          <asp:NextPreviousPagerField ButtonType="Button"
            ShowPreviousPageButton="false" />
          <asp:NumericPagerField ButtonCount="10" />
          <asp:NextPreviousPagerField ButtonType="Button"
            ShowPreviousPageButton="false" />

      <!-- 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="ProductsDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
        SelectCommand="SELECT P.ProductID, P.Name, P.Color, P.ListPrice, 
          FROM Production.Product AS P 
          INNER JOIN Production.ProductProductPhoto AS PPF ON P.ProductID = PPF.ProductID 
          INNER JOIN Production.ProductPhoto AS PF ON PPF.ProductPhotoID = PF.ProductPhotoID">


Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5