How to add a new field each time a button is clicked
<p>I want to create a new fileupload field each time i click on a button.
i have a form in a page and i want to add the fields to that form.
i tried to save an array of fileupload fields in a session but it deosnt seem to work.</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
        this.Session["fileUploadArray"] = new FileUpload[5];

}
protected void Button1_Click(object sender, EventArgs e)
{
    FileUpload[] flArray = ((FileUpload[])(this.Session["fileUploadArray"]));
    for (int i = 0; i &lt; flArray.Length; i++)
    {
        if (flArray[i] == null)
        { 
            flArray[i] = new FileUpload();
            form1.Controls.Add(flArray[i]);
            this.Session["fileUploadArray"] = flArray;
            return;
        }
    }
}
</code></pre>
