Trouble using findcontrol to find values from dynamic Literal Control
<p>I'm having problems with finding my controls in my dynamically created literal control. I want to be able to grab the value in the label with the <code>fnameID(x)</code> id.</p>

<p>ASPX:</p>

<pre><code>&lt;div&gt;
  &lt;asp:Panel ID="Panel1" runat="server"&gt;
  &lt;/asp:Panel&gt;
&lt;/div&gt;
&lt;asp:Button ID="Button1" runat="server" Text="Button" 
    onclick="Button1_Click" /&gt;
</code></pre>

<p>CODE BEHIND:</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
    for (int i = 0; i &lt; 50; i++)
    {
        CheckBox _checkbox = new CheckBox();
        _checkbox.ID = "dynamicCheckListBox" + Convert.ToString(i);
        Panel1.Controls.Add(_checkbox);
        Panel1.Controls.Add(new LiteralControl("&lt;Label id='fnameID" 
            + i + "' &gt;test" + i + "&lt;/Label&gt;&lt;br/&gt;"));
    }

}

protected void Button1_Click(object sender, EventArgs e)
{
    Label lbl = (Label)Panel1.FindControl("fnameID0");
    Response.Write(lbl.Text);
}
</code></pre>

<p>Currently I am getting the following error when I click on the button:</p>

<pre><code>Object reference not set to an instance of an object.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
</code></pre>

<p>Source Error:</p>

<pre><code>{
Label lbl = (Label)Page.FindControl("fnameID0");
**Response.Write(lbl.Text);**
}
</code></pre>
