title: Using ListView and Repeater together
body: <p>I would like to put Repeater inside a Repeater.  Since my list view has both ItemTemplate and AlternateItemTemplate, do I need to add two repeaters and bind both repeaters?</p>
  
  <pre><code>&lt;asp:ListView ID="lvData" runat="server" onitemdatabound="lvData_ItemDataBound"&gt;
      &lt;layouttemplate&gt;
          &lt;div style="border:dotted 1px gray;"&gt;
              &lt;asp:PlaceHolder ID="itemPlaceholder" runat="server" /&gt;
          &lt;/div&gt;
      &lt;/layouttemplate&gt;
      &lt;itemtemplate&gt;
          &lt;div class="ListView"&gt;
              &lt;h5&gt;&lt;%# Eval("CourseCode") %&gt; - &lt;%# Eval("CourseName") %&gt;&lt;/h5&gt; 
               &lt;asp:Repeater ID="rptComments" runat="server"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;p&gt;
                          &lt;%# DataBinder.Eval(Container.DataItem, "Comment") %&gt;&lt;/p&gt;
                  &lt;/ItemTemplate&gt;
                  &lt;FooterTemplate&gt;
                      &lt;asp:Label ID="lblEmpty" Text="No comments to display..." runat="server" Visible='&lt;%#bool.Parse((rptComments.Items.Count==0).ToString())%&gt;'&gt;&lt;/asp:Label&gt;
                  &lt;/FooterTemplate&gt;
              &lt;/asp:Repeater&gt; 
          &lt;/div&gt;
      &lt;/itemtemplate&gt;
      &lt;alternatingitemtemplate&gt;
          &lt;div class="ListViewAlternate"&gt;
              &lt;h5&gt;&lt;%# Eval("CourseCode") %&gt; - &lt;%# Eval("CourseName") %&gt;&lt;/h5&gt;        
              &lt;asp:Repeater ID="rptComments2" runat="server"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;p&gt;
                          &lt;%# DataBinder.Eval(Container.DataItem, "Comment") %&gt;&lt;/p&gt;
                  &lt;/ItemTemplate&gt;
                  &lt;FooterTemplate&gt;
                      &lt;asp:Label ID="lblEmpty" Text="No comments to display..." runat="server" Visible='&lt;%#bool.Parse((rptComments.Items.Count==0).ToString())%&gt;'&gt;&lt;/asp:Label&gt;
                  &lt;/FooterTemplate&gt;
              &lt;/asp:Repeater&gt;
          &lt;/div&gt;
      &lt;/alternatingitemtemplate&gt;
      &lt;emptydatatemplate&gt;
      No records to display.
  &lt;/emptydatatemplate&gt;
  &lt;/asp:ListView&gt;
  </code></pre>