---
title: "FileUpload upload codebehind."  
description: "FileUpload upload codebehind."  
author: "marcel ethan"  
published: 2014-08-28  
updated: 2014-08-28  
canonical: https://www.mindstick.com/forum/2191/fileupload-upload-codebehind  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# FileUpload upload codebehind.

```
        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](https://www.mindstick.com/blog/301635/did-people-reinvent-texting-to-express-the-full-range-of-emotions) 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](https://www.mindstick.com/articles/59/encrypting-and-decrypting-files-using-c-sharp) from the [FileUpload](https://www.mindstick.com/forum/428/is-there-a-way-to-check-fileupload-has-file-or-not-in-client-side-if-it-has-i-want-to-enable-button) [controls](https://www.mindstick.com/articles/66/how-to-create-controls-at-run-time-in-csharp-dot-net)? Cant seem to do above with FileUpload.

## Replies

### Reply by Sumit Kesarwani

Hi marcel,

Got it working with this, thought i had tryed that. Apparently not good enough :)

```
 var countUploads =ChildrenCountTextPanel.Controls.OfType<FileUpload>();        FileUpload FileUl = new FileUpload();        foreach (var ul in countUploads)        {           
if(ul.ID.Contains("imgUpload_"))            {                FileUl= ul;                           }        }if (FileUl.HasFile){ ConvertAndSave(FileUl) }
```


---

Original Source: https://www.mindstick.com/forum/2191/fileupload-upload-codebehind

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
