private void SetChildrenCountControls(int total)
{
for (int i =0; i < total; i++)
{
var tbBirthDate = new TextBox();
tbBirthDate.ID = "tbBirthDate_" + (i + 1);
tbBirthDate.CssClass = "tbSister_input";
tbBirthDate.EnableViewState = true;
FileUpload upload = new FileUpload();
upload.ID= "imgUpload_" + (i + 1);
upload.CssClass = "tbSister_upload";
upload.EnableViewState = true;
ChildrenCountTextPanel.Controls.Add(tbBirthDate);
ChildrenCountTextPanel.Controls.Add(upload);
}
}
And can get the enterede text in the txtbox with:
protected void lbFamilySave_Click(object sender, EventArgs e)
{
var countSisters = ChildrenCountTextPanel.Controls.OfType<TextBox>();
string sisterBirth = string.Empty;
foreach (var sister in countSisters)
{
if(sister.ID.Contains("tbBirthDate_"))
sisterBirth = sister.Text;
}
}
How can i get the file from the FileUpload controls? Cant seem to do above with FileUpload.
Sumit Kesarwani
28-Aug-2014Got it working with this, thought i had tryed that. Apparently not good enough :)