Export (0) Print
Expand All
Expand Minimize

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)

<BrowsableAttribute(False)> _
<PersistenceModeAttribute(PersistenceMode.InnerProperty)> _
<TemplateContainerAttribute(GetType(ListViewItem))> _
Public Overridable Property GroupSeparatorTemplate As ITemplate

Property Value

Type: System.Web.UI.ITemplate
An object that contains the custom content for the group separator. The default is Nothing, 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="VB" %>

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

<html xmlns="http://www.w3.org/1999/xhtml" >
  <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">


.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

© 2014 Microsoft