How do I add controls dynamically to a dynamically created panel?
<p>I have a repeater that creates n-number of panels. I am trying to dynamically add  different controls to each of the panels. I may very well be going about this the wrong way.</p>

<p>My code is more or less:</p>

<p>.aspx:</p>

<pre><code>   &lt;asp:Repeater ID="Repeater1" runat="server"&gt;
    &lt;ItemTemplate&gt;
        &lt;% Response.Write("&lt;asp:panel runat=\"server\" id=\"uxPanel_"); %&gt;
        &lt;%# DataBinder.Eval(Container.DataItem, "TableId")%&gt;&lt;% Response.Write("\"&gt;&lt;/asp:panel&gt;"); %&gt;

    &lt;/ItemTemplate&gt;
&lt;/asp:Repeater&gt;
</code></pre>

<p>.cs:</p>

<pre><code>public partial class class1: System.Web.UI.Page
{
  DataSet ds= null;
protected void Page_Load(object sender, EventArgs e)
{
    GetRecords(1,1);
}

protected void GetRecords()
{
    ds= dal.LoadRecords();

    this.Repeater1.DataSource = ds.Tables[0];
    this.Repeater1.DataBind();


    Literal lit = new Literal();
    lit.Text = "Some text";
    this.FindControl("uxPanel_1").Controls.Add(lit);        


}
</code></pre>

<p>}</p>

<p>Just to be clear in this example "dal.LoadRecords" is simply call to a method that retrieves some records from a DB. </p>

<p>I think my problem is how I am adding my panels in the first place, but this seemed like an easy way to have them uniquely named.</p>

<p>Any Pointers? </p>

<p>Thanks</p>
