forum

Home / DeveloperSection / Forums / Adressing a fileupload within a repeater

Adressing a fileupload within a repeater

Anonymous User270125-Aug-2014

i have my fileupload within my repeater

  <asp:Content ID="Content3" ContentPlaceHolderID="content" Runat="Server">

<asp:Repeater ID="rptVrijstellingen" runat="server">

        <HeaderTemplate></HeaderTemplate>

        <ItemTemplate>

        <h2><%# Eval("tblExternVak.ExternvakNaam") %></h2>

        <h4>Selecteer een bestand om te uploaden:</h4>

       Gelieve het bestand de naam te geven van het overeenkomstige vak om de verwerking

           vlot te laten verlopen.

           <br /><br />  <br />

           <asp:FileUpload id="FileUpload1"                

           runat="server">

           </asp:FileUpload>

       <br /><br />

       <hr />

       <br />

         <br />

        <asp:Button id="UploadButton"

           Text="Upload file"

           OnClick="UploadButton_Click"

           runat="server">

       </asp:Button>    

       <br />   

    <br />

            </ItemTemplate>

        <SeparatorTemplate><hr /></SeparatorTemplate>

        </asp:Repeater>   

       <asp:CheckBox id="CBupload" runat="server" />

       <asp:Label id="lblUpload" runat="server"> Geleverd aan Mevrouw Van Orlé</asp:Label>

       <asp:Label id="UploadStatusLabel" runat="server" ForeColor="Red"></asp:Label>  

</asp:Content>

And i want to adress it from my classfile

   if (FileUpload1.HasFile)

    {

        try

        {

            String fileName = FileUpload1.FileName;

            savePath += fileName;

            FileUpload1.SaveAs(Server.MapPath(savePath));

            tblBijlage s = new tblBijlage();

            s.bijlageTitel = fileName;

            s.bijlageURL = savePath;

            s.bijlageType = "1";

            s.fk_externvakID = 2;

            BLLstudent BLLstudent = new BLLstudent();

            BLLstudent.insertFile(s);

        }

        catch (Exception ex)

        {

            UploadStatusLabel.Text = ex.Message;

        }

    }

    else

    {

      UploadStatusLabel.Text = "Gelieve een bestand te kiezen";

    }

    }

}

The problem is it doesnt find fileupload1 and any other declared stuff within the repeater, can anyone present me a solution on how to adress the upload within the repeater? (I fill up the repeater with data in my page_load so it exists on load so i know that is not the problem)

Thank you in advance 


Updated on 25-Aug-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By