title: ASP.NET Gridview ButtonField onclick fires containing row's onclick event
body: <p>I have a gridview row that when clicked has to do postback A and a buttonfield in that row that when clicked has to do postback B. The problem is that when i click on the buttonfield, both event1 and event2 gets fired. Below is the code.</p>
  
  <pre><code>protected void gdv_RowCommand(object sender, GridViewCommandEventArgs e)
  {
      string arg = Convert.ToString(((System.Web.UI.WebControls.CommandEventArgs)(e)).CommandArgument);
  
      if (e.CommandName == "Command1")
      {
          doEvent1(arg);
      }
      else if (e.CommandName == "Command2")
      {
          doEvent2(arg);
      }
  }
  
  protected void gdv_RowDataBound(object sender, GridViewRowEventArgs e)
  {
      if (e.Row.RowType == DataControlRowType.DataRow)
      {            
          LinkButton b1 = (LinkButton)e.Row.Cells[0].Controls[0];
          matchesButton.CommandArgument = arg1;
  
          LinkButton rowLink = (LinkButton)e.Row.Cells[1].Controls[1];
          rowLink.CommandArgument = arg2;
  
          e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(rowLink, "");
      }
  }
  </code></pre>
  
  <p>And this is the asp code for the gridview</p>
  
  <pre><code>&lt;Columns&gt;
      &lt;asp:ButtonField DataTextField="f1" HeaderText="H1" CommandName="Command1" /&gt;
      &lt;asp:TemplateField&gt;
          &lt;ItemTemplate&gt;
              &lt;asp:LinkButton ID="btn1" runat="server" Text="" CommandName="Command2" /&gt;
          &lt;/ItemTemplate&gt;
      &lt;/asp:TemplateField&gt;
  &lt;/Columns&gt;
  </code></pre>