Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7887423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:34:35+00:00 2026-06-03T05:34:35+00:00

I have an ASP.NET Repeater control with a FileUpload Control in its item template.

  • 0

I have an ASP.NET Repeater control with a FileUpload Control in its item template. The ASP.NET Repeater is inside an UpdatePanel as part of a wizard made from an ASP.NET Multiview. I am trying to upload every file in each FileUpload control when I click submit, but the FileUpload controls do not retain a file when I submit the form. Here is the relevant code:

<asp:Repeater ID="RepeaterImages" runat="server" OnItemCommand="RepeaterBoxArts_ItemCommand">
  <ItemTemplate>
    <tr>
       <td class="right">
          Choose File:
       </td>
       <td>
           <asp:FileUpload ID="FileUpload" runat="server" />
       </td>
    </tr>
  </ItemTemplate>

foreach (RepeaterItem item in RepeaterImages.Items)
    {
        if (item.ItemType == ListItemType.Item
            || item.ItemType == ListItemType.AlternatingItem)
        {
            FileUpload fupload = (FileUpload)item.FindControl("FileUpload");
             if (fupload.HasFile)
            {
                string path = Server.MapPath("~/images/");
                fupload.SaveAs(path);

            }
        }
    }

When I click Submit, I want all FileUpload controls with a file to upload their files. However, if I run the step debugger, it shows each FileUpload control as not having a file. It seems to be an issue with postbacks, but I’m not 100% sure.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:34:36+00:00Added an answer on June 3, 2026 at 5:34 am

    I had the same problem and solved adding this code

    OnClientClick=”javascript:document.forms[0].encoding = ‘multipart/form-data’;”

    at the button that will upload all images.

    The answer of this problem, I found at this link https://stackoverflow.com/a/217722

    See my code below:

    In the page ASPX

    <asp:Repeater ID="rptUpload" runat="server" OnItemDataBound="rptUpload_ItemDataBound">
                                <HeaderTemplate>
                                    <table width="100%">
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <tr>
                                        <td>
                                            <asp:FileUpload ID="fu" runat="server" />
                                        </td>
                                    </tr>
                                </ItemTemplate>
                                <FooterTemplate>
                                    </table>
                                </FooterTemplate>
                            </asp:Repeater>
    
                            <p>
                                <asp:ImageButton ID="btnUpload" runat="server" OnClick="btnUpload" ImageUrl="img/icon_upload.png" OnClientClick="javascript:document.forms[0].encoding = 'multipart/form-data';" />
                            </p>
    

    In the CodeBehind

    protected void btnUpload_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                foreach (RepeaterItem item in rptUpload.Items)
                {
                    if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                    {
                        FileUpload fu = (FileUpload)item.FindControl("fu");
                        if (fu.HasFile)
                        {
                            string path = Server.MapPath("~/images/");
                            string fileName = Path.GetFileName(fu.FileName);
                            string fileExt = Path.GetExtension(fu.FileName).ToLower();
                            fu.SaveAs(path + fileName + fileExt);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DropDownList inside a repeater control in an ASP.NET page that has
I have an ASP.NET control that binds data to a repeater. Inside that repeater,
I use asp.net and c#4. I have a repeater within inside a HyperLink Control.
I have a asp.net repeater control in a aspx page, with runat=server and an
I have come across the ASP.NET ready made controls like grid, repeater... etc. For
i have a asp.net repeater control .I have to display only two rows in
I have an ASP.NET Repeater control, where a number of the following instances of
I have a designed landing page in asp.net 4.0 i am using repeater control
I have an ASP.NET repeater pulling comment data from a database. In my ItemTemplate
I have an asp.net repeater control with a series of asp:hyperlink's <asp:HyperLink runat=server ID=name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.