Note that there are some explanatory texts on larger screens.

plurals
  1. POgridview row onclick event prevent template button onclick in each row to fire in google chrome and safari but it works in IE and firefox
    text
    copied!<p>I have a gridview,inside each row I have a button with commandName "Activate". I also add onclick behaviour to gridview row to select the row and show the form with some info. the problem is: when i click on button instead of Activate command, Select command will fire.</p> <p>here is how I did this:</p> <pre><code> &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:Button CommandName="Activate" ID="btnActivate" runat="server" Text="Activate" CausesValidation="false"&gt;&lt;/asp:Button&gt; &lt;/ItemTemplate&gt; &lt;ItemStyle Wrap="false" /&gt; &lt;/asp:TemplateField&gt; </code></pre> <p>then I manage the command here:</p> <pre><code> protected void gridview_RowCommand(object sender, GridViewCommandEventArgs e) { switch (e.CommandName.ToUpper()) { case "SELECT": GridViewRow row1=(GridViewRow)grvCustomerCredit.Rows[Convert.ToInt32(e.CommandArgument)]; selectedRowIndex = row1.RowIndex; txbCC_CITY.Text = row1.Cells[4].Text; txbCC_PROVINCE.Text = row1.Cells[5].Text; row1.ForeColor = System.Drawing.Color.White; break; case "ACTIVATE": GridViewRow row2 = (GridViewRow)((Control)e.CommandSource).Parent.Parent; creditID = Convert.ToInt32(gridview.DataKeys[row2.RowIndex].Value); {do the Activate Action} break; } } </code></pre> <p>and this is how I add onclick on each row:</p> <pre><code> protected override void Render(System.Web.UI.HtmlTextWriter writer) { foreach (GridViewRow row in gridview.Rows) { row.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(gv, "Select$" + row.RowIndex.ToString(), true)); } base.Render(writer); } </code></pre> <p>before adding the onclick on gridview row Activate button was working fine. how can I set the first priority to button click not row click? any idea?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload