title: gridview edit mode is not getting fired on single click
body: <p>I want to edit the record in gridview on single click. My gridview is placed inside update panel. 
  There is a search textbox given and  when I type anything in search textbox "txt_Search_TextChanged" event is fired and that text is searched in database and that particular record is fetched and bind to the grid.</p>
  
  <p>Now my problem is: If I click on edit button of grid without searching, then event is fired. But if I search any record and then I click on edit button, it takes 2 click to give result. I have written a script for textbox which is as follows:</p>
  
  <pre><code>enter code here
                  &lt;script&gt;
              function RefreshUpdatePanel() {
              __doPostBack('&lt;%= txt_Search.ClientID %&gt;', '');
  
       };
  </code></pre>
  
  <p></p>
  
  <p>below is aspx code</p>
  
  <pre><code>&lt;table width="100%"&gt;
      &lt;tr&gt;
          &lt;td align="center"&gt;
              &lt;div style="border-width: 2px; border-style: solid; border-color: #FDAC4C; width: 95%; border-radius: 10px;"&gt;
                  &lt;asp:UpdatePanel ID="UpdatePanel3" runat="server"&gt;
                      &lt;ContentTemplate&gt;
                          &lt;asp:GridView ID="grd_Master" ShowFooter="false" runat="server" Width="98%" AllowPaging="true" PagerStyle-CssClass="paging"
                              OnPageIndexChanging="grd_Master_PageIndexChanging"
                              PageSize="8" AutoGenerateColumns="False" BorderWidth="0" BorderStyle="Solid" BorderColor="#FDAC4C" OnRowEditing="grd_Master_RowEditing" ShowHeaderWhenEmpty="true"&gt;
                              &lt;AlternatingRowStyle BackColor="#FFFFFF" Height="30px" BorderStyle="Dotted" BorderWidth="1"
                                  BorderColor="#DDDDDD" /&gt;
                              &lt;RowStyle BackColor="#FFF0DD" Height="30px" BorderStyle="Dotted" BorderWidth="1"
                                  BorderColor="#DDDDDD" /&gt;
  
                              &lt;Columns&gt;
                                  &lt;asp:TemplateField&gt;
                                      &lt;HeaderTemplate&gt;
                                          Serial No.&lt;br /&gt;
  
                                      &lt;/HeaderTemplate&gt;
                                      &lt;HeaderStyle HorizontalAlign="Left"&gt;&lt;/HeaderStyle&gt;
                                      &lt;ItemStyle HorizontalAlign="Right" Width="10%" CssClass="grdrow"&gt;&lt;/ItemStyle&gt;
                                      &lt;ItemTemplate&gt;
                                          &lt;asp:Label ID="lblSRNO" runat="server" Style="padding-right: 50px" Text='&lt;%#Container.DataItemIndex+1 %&gt;'&gt;&lt;/asp:Label&gt;
                                          &lt;asp:Label ID="Cooling_Code" runat="server" Visible="false" Text='&lt;% #Bind("Cool_Code")%&gt;'&gt;&lt;/asp:Label&gt;
                                          &lt;asp:Label ID="lblProdGrpCode" runat="server" Style="padding-left: 100px" Text='&lt;% #Bind("Prod_Grp_Code")%&gt;' Visible="false"&gt;&lt;/asp:Label&gt;
                                          &lt;asp:Label ID="lblSubProdGrpCode" runat="server" Style="padding-left: 100px" Text='&lt;% #Bind("Sub_Prod_Code")%&gt;' Visible="false"&gt;&lt;/asp:Label&gt;
                                          &lt;asp:Label ID="lblMakeCode" runat="server" Style="padding-left: 100px" Text='&lt;% #Bind("Make_Code")%&gt;' Visible="false"&gt;&lt;/asp:Label&gt;
                                          &lt;asp:Label ID="lblRegerCode" runat="server" Style="padding-left: 100px" Text='&lt;% #Bind("Refg_Code")%&gt;' Visible="false"&gt;&lt;/asp:Label&gt;
                                          &lt;asp:Label ID="lblCompressorCode" runat="server" Style="padding-left: 100px" Text='&lt;% #Bind("Comp_Code")%&gt;' Visible="false"&gt;&lt;/asp:Label&gt;
                                          &lt;asp:Label ID="lblFilePath" runat="server" Visible="false" Style="padding-left: 100px" Text='&lt;% #Bind("Document_Path")%&gt;'&gt;&lt;/asp:Label&gt;
                                      &lt;/ItemTemplate&gt;
                                      &lt;HeaderStyle CssClass="grdheader" Width="10%" /&gt;
                                  &lt;/asp:TemplateField&gt;
  
                                  &lt;asp:TemplateField&gt;
                                      &lt;HeaderTemplate&gt;
                                          Cooling Name 
                                      &lt;/HeaderTemplate&gt;
                                      &lt;HeaderStyle HorizontalAlign="Left"&gt;&lt;/HeaderStyle&gt;
                                      &lt;ItemStyle HorizontalAlign="Left" Width="20%" CssClass="grdrow"&gt;&lt;/ItemStyle&gt;
                                      &lt;ItemTemplate&gt;
                                          &lt;asp:Label ID="lblCoolingName" runat="server" Style="padding-left: 10px" Text='&lt;% #Bind("Cool_Name")%&gt;'&gt;&lt;/asp:Label&gt;
                                      &lt;/ItemTemplate&gt;
                                      &lt;HeaderStyle CssClass="grdheader" Width="20%" /&gt;
                                  &lt;/asp:TemplateField&gt;
  
                                  &lt;asp:TemplateField&gt;
                                      &lt;HeaderTemplate&gt;
                                          Short Name
                                      &lt;/HeaderTemplate&gt;
                                      &lt;HeaderStyle HorizontalAlign="Left" CssClass="grdheader" Width="15%"&gt;&lt;/HeaderStyle&gt;
                                      &lt;ItemStyle HorizontalAlign="Left" Width="15%" CssClass="grdrow"&gt;&lt;/ItemStyle&gt;
  
                                      &lt;ItemTemplate&gt;
                                          &lt;asp:Label ID="lblCoolingShortName" runat="server" Style="padding-left: 10px" Text='&lt;% #Bind("Cool_Short_Name")%&gt;'&gt;&lt;/asp:Label&gt;
                                      &lt;/ItemTemplate&gt;
  
                                  &lt;/asp:TemplateField&gt;
                                  &lt;asp:TemplateField&gt;
                                      &lt;HeaderTemplate&gt;
                                          Cooling Description
                                      &lt;/HeaderTemplate&gt;
                                      &lt;ItemStyle HorizontalAlign="left" Width="45%" CssClass="grdrow"&gt;&lt;/ItemStyle&gt;
                                      &lt;ItemTemplate&gt;
                                          &lt;asp:Label ID="lblCoolingDescr" runat="server" Style="padding-left: 10px" Text='&lt;% #Bind("Cool_Descr")%&gt;'&gt;&lt;/asp:Label&gt;
                                      &lt;/ItemTemplate&gt;
                                      &lt;HeaderStyle HorizontalAlign="Left" CssClass="grdheader" Width="45%"&gt;&lt;/HeaderStyle&gt;
                                  &lt;/asp:TemplateField&gt;
                                  &lt;asp:TemplateField&gt;
                                      &lt;HeaderTemplate&gt;
                                          Action&lt;br /&gt;
  
                                      &lt;/HeaderTemplate&gt;
                                      &lt;HeaderStyle HorizontalAlign="Left" CssClass="grdheader" Width="10%"&gt;&lt;/HeaderStyle&gt;
                                      &lt;ItemStyle HorizontalAlign="Center" Width="10%" CssClass="grdrow"&gt;&lt;/ItemStyle&gt;
                                      &lt;ItemTemplate&gt;
                                          &lt;asp:ImageButton ID="imgbtnEdit" runat="server" ImageUrl="~/images/Edit.png" Width="20px" ToolTip="Edit" CommandName="Edit" Height="20px" /&gt;
                                          &lt;asp:ImageButton ID="ImageDelete" runat="server" ImageUrl="~/images/trash1.png" ToolTip="Delete" OnClick="ImageDelete_Click" Width="25px" Height="20px" OnClientClick="return confirmDelete()" /&gt;
                                      &lt;/ItemTemplate&gt;
                                  &lt;/asp:TemplateField&gt;
  
                              &lt;/Columns&gt;
                              &lt;PagerStyle HorizontalAlign="Left" BorderWidth="0" BorderStyle="None" /&gt;
  
                          &lt;/asp:GridView&gt;
                      &lt;/ContentTemplate&gt;
                      &lt;Triggers&gt;
                          &lt;asp:AsyncPostBackTrigger ControlID="txt_Search" /&gt;
                          &lt;asp:PostBackTrigger ControlID="grd_Master" /&gt;
                      &lt;/Triggers&gt;
                  &lt;/asp:UpdatePanel&gt;
              &lt;/div&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Below is cs code for rowediting</p>
  
  <pre><code>protected void grd_Master_RowEditing(object sender, GridViewEditEventArgs e)
  {
      try
      {
          tab0.Enabled = false;
          tab1.Enabled = true;
  
          grd_Master.EditIndex = e.NewEditIndex;
          GridViewRow rw = (GridViewRow)grd_Master.Rows[e.NewEditIndex];
          Label CoolingCode = (Label)rw.FindControl("Cooling_Code");
          Label ProdgrpCode = (Label)rw.FindControl("lblProdGrpCode");
          Label SubProdCode = (Label)rw.FindControl("lblSubProdGrpCode");
          Label MakeCode = (Label)rw.FindControl("lblMakeCode");
          Label ReferCode = (Label)rw.FindControl("lblRegerCode");
          Label CompressoreCode = (Label)rw.FindControl("lblCompressorCode");
          Label CoolingName = (Label)rw.FindControl("lblCoolingName");
          Label CoolingName_Short = (Label)rw.FindControl("lblCoolingShortName");
          Label CoolingName_Desc = (Label)rw.FindControl("lblCoolingDescr");
          Label lblFilePath = (Label)rw.FindControl("lblFilePath");
  
  
  
  
          txtCoolType.Text = CoolingName.Text.Trim();
          txtCoolTypeShortname.Text = CoolingName_Short.Text.Trim();
          txtCoolTypeDescrip.Text = CoolingName_Desc.Text.Trim();
  
          ddlProdGrp.SelectedValue = ProdgrpCode.Text;
          ddlSubProd.SelectedValue = SubProdCode.Text;
          ddlMake.SelectedValue = MakeCode.Text;
          ddlCompressor.SelectedValue = CompressoreCode.Text;
          ddlRefe.SelectedValue = ReferCode.Text;
  
          btnsave.Text = "Update";
          ViewState["CoolingCode"] = CoolingCode.Text;
          TabContainer_Item.ActiveTabIndex = 1;
  
          Session["CoolingCode"] = CoolingCode.Text;
          this.fu1.BindGridDoc();
      }
      catch (Exception ex)
      {
  
          Master.ErrorMessage(ex.Message);
      }
  }
  
  protected void txt_Search_TextChanged(object sender, EventArgs e)
  {
      try
      {
          DataSet ds = gn.ExecuteDataset("Search_CoolingType", txt_Search.Text.Trim());
  
          ViewState["CoolingTypeData"] = ds.Tables[0];
          if (ds.Tables[0].Rows.Count == 0)
          {
              FillEmptyGrid();
  
          }
          else
          {
  
              grd_Master.DataSource = ds;
              grd_Master.DataBind();
  
          }
      }
  
      catch (Exception ex)
      {
          Master.ErrorMessage(ex.Message);
      }
  }
  </code></pre>