title: fileupload not working within gridview inside update panel
body: <p>i have file upload control in gridview and that gridview is inside update panel
  when i try to update gridview everything works but image path from fileupload don't save
  please help me...</p>
  
  <p>page.aspx</p>
  
  <pre><code>&lt;asp:GridView ID="GridView1" runat="server"  AutoGenerateColumns="False" BackColor="White" 
                                  BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4" CellSpacing="4" 
                                  DataKeyNames="pid" ForeColor="Black" ShowHeaderWhenEmpty="True" 
                                  GridLines="Horizontal" onrowediting="GridView1_RowEditing" 
                                  onrowupdating="GridView1_RowUpdating" 
                                  onrowcancelingedit="GridView1_RowCancelingEdit" 
                                  onrowdeleting="GridView1_RowDeleting"&gt;
                                  &lt;Columns&gt;
                                      &lt;asp:TemplateField HeaderText="Operation"&gt;
                                          &lt;EditItemTemplate&gt;
                                              &lt;asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update"&gt;&lt;/asp:LinkButton&gt;&amp;nbsp;
                                              &lt;asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"&gt;&lt;/asp:LinkButton&gt;
                                          &lt;/EditItemTemplate&gt;
                                          &lt;ItemTemplate&gt;
                                              &lt;asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" ForeColor="#94b52c"&gt;&lt;/asp:LinkButton&gt;&amp;nbsp;
                                              &lt;asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" ForeColor="#94b52c"
                                                              OnClientClick="return confirm('Are You Sure Want To Delete ?');"&gt;&lt;/asp:LinkButton&gt;
                                          &lt;/ItemTemplate&gt;
                                          &lt;HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
                                          &lt;ItemStyle Font-Bold="True" HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
                                      &lt;/asp:TemplateField&gt;
                                      &lt;asp:TemplateField HeaderText="Product ID" InsertVisible="False" SortExpression="pid"&gt;
                                          &lt;EditItemTemplate&gt;
                                              &lt;asp:Label ID="lblpid" runat="server" Text='&lt;%# Eval("pid") %&gt;'&gt;&lt;/asp:Label&gt;
                                          &lt;/EditItemTemplate&gt;
                                          &lt;ItemTemplate&gt;
                                              &lt;asp:Label ID="lblproductid" runat="server" Text='&lt;%# Bind("pid") %&gt;'&gt;&lt;/asp:Label&gt;
                                          &lt;/ItemTemplate&gt;
                                          &lt;HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
                                          &lt;ItemStyle Font-Bold="True" HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
                                      &lt;/asp:TemplateField&gt;
                                      &lt;asp:TemplateField HeaderText="Product Detail" SortExpression="pdetail"&gt;
                                          &lt;EditItemTemplate&gt;
                                              &lt;asp:TextBox ID="txtproductdetail" runat="server" Text='&lt;%# Bind("pdetail") %&gt;'&gt;&lt;/asp:TextBox&gt;
                                          &lt;/EditItemTemplate&gt;
                                          &lt;ItemTemplate&gt;
                                              &lt;asp:Label ID="lblproductdetail" runat="server" Text='&lt;%# Bind("pdetail") %&gt;'&gt;&lt;/asp:Label&gt;
                                          &lt;/ItemTemplate&gt;
                                          &lt;HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
                                          &lt;ItemStyle Font-Bold="True" HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
                                      &lt;/asp:TemplateField&gt;
                                      &lt;asp:TemplateField HeaderText="Product Image" SortExpression="pimage"&gt;
                                          &lt;EditItemTemplate&gt;
                                              &lt;asp:FileUpload ID="FileUpload1" runat="server" /&gt;
                                          &lt;/EditItemTemplate&gt;
                                          &lt;ItemTemplate&gt;
                                              &lt;asp:Image ID="imgproductimage" runat="server" ImageUrl='&lt;%# Bind("pimage") %&gt;' Height="50px" Width="50px"/&gt;
                                          &lt;/ItemTemplate&gt;
                                          &lt;HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
                                          &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
                                      &lt;/asp:TemplateField&gt;
  
                                  &lt;/Columns&gt;
                                  &lt;FooterStyle BackColor="#F0F0F0" ForeColor="Black" /&gt;
                                  &lt;HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" VerticalAlign="Middle"  /&gt;
                                  &lt;PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" /&gt;
                                  &lt;SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" /&gt;
                                  &lt;SortedAscendingCellStyle BackColor="#F7F7F7" /&gt;
                                  &lt;SortedAscendingHeaderStyle BackColor="#4B4B4B" /&gt;
                                  &lt;SortedDescendingCellStyle BackColor="#E5E5E5" /&gt;
                                  &lt;SortedDescendingHeaderStyle BackColor="#242121" /&gt;
                              &lt;/asp:GridView&gt;
      &lt;/ContentTemplate&gt;
                          &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>here is .cs file</p>
  
  <pre><code> public void bindgrid()
  {
      string qry = "select pid,pdetail,pimage from productdetail p,categorydetail c where p.cid=c.cid";
      GridView1.DataSource = abal.Qry_Fire(qry);
      GridView1.DataBind();
  }
  protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
  {
      GridView1.EditIndex = e.NewEditIndex;
      bindgrid();
  }
  protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
  {
      Label l = (Label)GridView1.Rows[e.RowIndex].FindControl("lblpid");
      TextBox txtproductdetail = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtproductdetail");
      FileUpload f = (FileUpload)GridView1.Rows[e.RowIndex].FindControl("FileUpload1");
      string path = "~/user/product_image/" + f.FileName.ToString();
      int msg = abal.Qry_All("update productdetail set pdetail='" + txtproductdetail.Text + "',pimage='" + path 
  
  + "' WHERE pid='" + Convert.ToInt32(l.Text) + "'");
      if(msg==1)
          f.SaveAs(Server.MapPath(path));
      GridView1.EditIndex = -1;
      bindgrid();
  }
  </code></pre>