Hello everyone,
I'm trying to get the values of dynamically generated FileUpload controls that I add to a Panel:
<asp:Panel ID="pFileControls" runat="server">
</asp:Panel>
I create the controls during a loop through a record set:
foreach(DataRow dr in ds.Tables[0].Rows)
{
FileUpload fu = new FileUpload();
fu.ID = dr["SomeID"].ToString();
pFileControls.Controls.Add(fu);
}
Everything works fine up to the point where I submit the form with this button:
<asp:Button ID="btnImportFile" runat="server" Text="Save" OnClick="btnImportFile_Click" />
Which I register like this (Page_Load):
ScriptManager.GetCurrent(this).RegisterPostBackControl(btnImportFile);
I do this because I'm using a MasterPage/ContentPage setting in my website and mostly everything happens inside an UpdatePanel for AJAXification purposes. Bear in mind that if I explicity specify a FileUpload Control in the HTML view, it works 100%.
When the form is submitted I try to iterate the Panel like this:
foreach (Control ctrl in pFileControls.Controls)
{
if (ctrl.GetType() != typeof(FileUpload))
{
continue;
}
//Do the saving of the file here
}
Except, the Panel seems to only return one control: The Content Place Holder for the page and nothing else. Does anyone have some ideas about this?