File upload button for each row inside gridview and button to upload in asp.net
<p>I need to have file upload button for each row in grid view. Finally I need a button to upload the files selected from fileupload button. I have a code, but it has both file upload button and button to update, however if I change the command name it is not working. Below is my code.</p>

<p>In my code I am displaying both fileupload buttons and buton updates. This works fine, but I need multiple file upload buttons with single button to update all the files.</p>

<pre><code>    &lt;asp:GridView ID="GridView1" runat="server"&gt;
            &lt;Columns&gt;
                &lt;asp:TemplateField&gt;
                    &lt;ItemTemplate&gt;
                        &lt;asp:FileUpload ID="FileUpload1" runat="server" /&gt;
                        &lt;asp:Button ID="Button1" runat="server" CommandArgument='&lt;%# Container.DataItemIndex  %&gt;'
                            Text="Upload" OnClick="Button1_Click" /&gt;
                    &lt;/ItemTemplate&gt;
                &lt;/asp:TemplateField&gt;
            &lt;/Columns&gt;
        &lt;/asp:GridView&gt;

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string[] strArray = { "Test1", "Test2", "Test3" };
            GridView1.DataSource = strArray;
            GridView1.DataBind();
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        int index = int.Parse(((Button)sender).CommandArgument);

        FileUpload file = (FileUpload)GridView1.Rows[index].FindControl("FileUpload1");

        if (file != null)
        {
            if (file.HasFile)
            {
                Response.Write(file.PostedFile.FileName);
                Response.End();
                //file.SaveAs(Server.MapPath("~") + "\\DataBind\\" + System.IO.Path.GetFileName(file.PostedFile.FileName));
            }
        }
    }
</code></pre>
