Textbox value null when trying to access it
<pre><code>namespace Dynamic_Controls.Dropdowndynamic
{
public partial class DropdowndynamicUserControl : UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (ControlCount != 0)
        {
            Recreatecontrols();
        }
    }

    private void Recreatecontrols()
    {
       // createtextboxes(ControlCount);
        createtextboxes(2);
    }

    protected void createtextboxes(int ControlCount)
    {
        DynPanel.Visible = true;
        for (int i = 0; i &lt;= ControlCount; i++)
        {
            TextBox tb = new TextBox();
            tb.Width = 150;
            tb.Height = 18;
            tb.TextMode = TextBoxMode.SingleLine;
            tb.ID = "TextBoxID" + this.DynPanel.Controls.Count;
            tb.Text = "EnterTitle" + this.DynPanel.Controls.Count;
            tb.Load+=new EventHandler(tb_Load);
            tb.Visible = true;
            tb.EnableViewState = true;
            DynPanel.Controls.Add(tb);
            DynPanel.Controls.Add(new LiteralControl("&lt;br/&gt;"));

        }

    }

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Int32 newControlCount = Int32.Parse(DropDownList1.SelectedValue);
        //createtextboxes(newControlCount);
        //ControlCount+=newControlCount;
        createtextboxes(2);
    }

    protected void Button1_Click(object sender, EventArgs e)
    {

        readtextboxes();

    }

    public void readtextboxes()
    {
        string x = string.Empty;
        for (int a = 0; a &lt; DynPanel.Controls.Count; a++)
        {
            foreach (Control ctrl in DynPanel.Controls)
            {
                if (ctrl is TextBox)
                {
                    x = ((TextBox)ctrl).Text;
                }
                x+=x+("\n");
            }

            Result.Text = x;
        }
    }

    private Int32 ControlCount
    {
        get
        {
            if (ViewState["ControlCount"] == null)
            {
                ViewState["ControlCount"] = 0;

            }
            return (Int32)ViewState["ControlCount"];
        }
        set
        {
           // ViewState["ControlCount"] = value;
            ViewState["ControlCount"] = 2;
        }
    }


    private void tb_Load(object sender, EventArgs e)
    {
        LblInfo.Text = ((TextBox)sender).ID + "entered"; 
    }
}
</code></pre>

<p>}</p>
