Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ItemSeparatorTemplate Property
Collapse the table of content
Expand the table of content

ListView.ItemSeparatorTemplate Property

Gets or sets the custom content for the separator between the items 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 ItemSeparatorTemplate As ITemplate

Property Value

Type: System.Web.UI.ITemplate
An object that contains the custom content for the separator between the items of the ListView control. The default is Nothing, which indicates that this property is not set.

Use the ItemSeparatorTemplate property to define the contents of the separator between single items of the ListView control. The ItemSeparatorTemplate is displayed after every item except the last one.

To specify the custom template declaratively, add an ItemSeparatorTemplate element inside the ListView control. You can then add the contents of the template to the ItemSeparatorTemplate element.

The following example shows how to create an item separator in the ListView control by using the ItemSeparatorTemplate 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.6, 4.5, 4, 3.5
© 2015 Microsoft