private void AddOneFileControl()
{
ArrayList al = new ArrayList();
this.tbFiles.Rows.Clear();
GetFileControlsFromSession();
HtmlTableRow htr = new HtmlTableRow();
HtmlTableCell htc = new HtmlTableCell();
htc.Controls.Add(new FileUpload());
htr.Controls.Add(htc);
this.tbFiles.Rows.Add(htr);
SaveCurrentPageFileControls();
}
private void GetFileControlsFromSession()
{
ArrayList al = new ArrayList();
if (Session["FilesControls"] != null)
{
al = (System.Collections.ArrayList)Session["FilesControls"];
for (int i = 0; i < al.Count; i++)
{
HtmlTableRow htr1 = new HtmlTableRow();
HtmlTableCell htc1 = new HtmlTableCell();
htc1.Controls.Add((System.Web.UI.WebControls.FileUpload)al[i]);
htr1.Controls.Add(htc1);
this.tbFiles.Rows.Add(htr1);
}
}
}
private void SaveCurrentPageFileControls()
{
ArrayList al = new ArrayList();
foreach (Control controlTR in this.tbFiles.Controls)
{
if (controlTR.GetType().ToString() == "System.Web.UI.HtmlControls.HtmlTableRow")
{
HtmlTableCell htc = (HtmlTableCell)controlTR.Controls[0];
foreach (Control controlFileUpload in htc.Controls)
{
if (controlFileUpload.GetType().ToString() == "System.Web.UI.WebControls.FileUpload")
{
FileUpload tempFileUpload = (FileUpload)controlFileUpload;
al.Add(tempFileUpload);
}
}
}
}
Session.Add("FilesControls", al);
}