title: Can I make a user control that is a list of user controls?
body: <p>I am created an asp.net web forms page, but I'm coming from MVC world and for reasons beyond my control, I have do use asp.net web forms, which I'm pretty clueless about.  I'm finding it difficult adjusting.  What I'm trying to do may not be possible - I'm trying to create a user control that is a list of user controls.  I'm probably using these things all wrong, but here's what I've got:</p>
  
  <p><strong>Single control item</strong></p>
  
  <pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeFile="testUserControl.ascx.cs" Inherits="testUserControl" %&gt;
  
  &lt;tr&gt;
      &lt;td&gt;&lt;%= this.NewsId %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= this.Title %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= this.Body %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= this.UserId %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= this.DateCreated %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= this.ImageId %&gt;&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p><strong>List control item</strong></p>
  
  <pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeFile="testListUserControl.ascx.cs" Inherits="testListUserControl" %&gt;
  &lt;%@ Reference Control="~/testUserControl.ascx" %&gt;
  
  &lt;table&gt;
      &lt;% foreach (var userControl in TestUserControlItem)
         {
             userControl
         } %&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p><strong>List control item code behind</strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  
  public partial class testListUserControl : System.Web.UI.UserControl
  {
      public List&lt;testUserControl&gt; TestUserControlItem { get; set; }
  }
  </code></pre>
  
  <p>The list item is where the problem is.  It doesn't work.  Can you see what I'm trying to do?  Is there a better way of doing this or of getting this to work?</p>