title: Calling button click on file upload inside gridview
body: <p>I'm trying to upload a file onchange event of the "Fileupload" control inside gridview.
  Means when ever user uploads the file, there itself I needs to save the file content in DB.
  So, I had mannually called the click event of the button control on the change of fileupload control But its throwing as like exception like "Invalid postback or callback argument...."</p>
  
  <p>my gridview code :</p>
  
  <pre><code>&lt;asp:GridView runat="server" ID="grd" AutoGenerateColumns="false"&gt;
      &lt;Columns&gt;
          &lt;asp:BoundField DataField="StudentID" HeaderText="Student ID" /&gt;
          &lt;asp:BoundField DataField="StudentName" HeaderText="Name" /&gt;
          &lt;asp:TemplateField HeaderText="Upload"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:FileUpload ID="FileUpload1" runat="server" EnableViewState="true" onChange="FileUploadCall(this)" /&gt;
                  &lt;asp:Button ID="btnUpload" Text="Upload" runat="server" OnClick="Upload" Style="display: none" /&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>My script Code :</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function FileUploadCall(fileUpload) {
          if (fileUpload.value != '') {
              var a = $('#&lt;%=grd.ClientID %&gt;').find('[id*="btnUpload"]');
              a.click();
          }
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>My Hidden Button mannual click creation in cs file :</p>
  
  <pre><code>protected void Upload(object sender, EventArgs e)
  {
      Button btn = sender as Button;
      GridViewRow gvr = (GridViewRow)btn.Parent.Parent;
  
      FileUpload lbleno = (FileUpload)gvr.FindControl("FileUpload1");
  
      lbleno.SaveAs(Server.MapPath("~/Uploads/" + Path.GetFileName(lbleno.FileName)));
      //lblMessage.Visible = true;
  }
  </code></pre>