title: How do you disable editmode in gridview?
body: <p>I have a gridview which works fine.  But it get into edit mode whenever command button is clicked.  Is there anyway to stop this?</p>
  
  <pre><code>&lt;asp:GridView id="grv_purchaseOrder" runat="server" AutoGenerateColumns="False" 
      onrowdatabound="grv_purchaseOrder_RowDataBound"  ShowFooter="True"
      EmptyDataText="No Purchase Order were found." DataKeyNames="purchaseOrderID" 
  onrowcommand="grv_purchaseOrder_RowCommand" 
      onrowediting="grv_purchaseOrder_RowEditing"&gt;
      &lt;Columns&gt;
          &lt;asp:TemplateField ShowHeader="False"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Button ID="but_purchaseOrderDetails" runat="server" CommandArgument='&lt;%# DataBinder.Eval(Container, "RowIndex") %&gt;'
                      CausesValidation="false" CommandName="edit" Text="Detail" /&gt;
              &lt;/ItemTemplate&gt;
              &lt;FooterTemplate&gt;
                  &lt;asp:Button ID="but_newOrderDetails" runat="server" CausesValidation="false"  commandargument="0"
                      CommandName="new" Text="New" /&gt;
              &lt;/FooterTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:BoundField DataField="name" HeaderText="Name" /&gt;
          &lt;asp:TemplateField HeaderText="Date"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="lbl_dateCreated" runat="server" Text='&lt;%# Bind("dateCreated") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:BoundField DataField="purchaseOrderStatus" HeaderText="Status" /&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Specifically the but_newOrderDetails is putting the gridview in edit mode.</p>
  
  <p>here is what's inside the Row Command event handler:</p>
  
  <pre><code>        string currentCommand = e.CommandName;
          ClientScriptManager cs = Page.ClientScript;
          int rowIndex = int.Parse(e.CommandArgument.ToString());
          string purchaseOrderID = grv_purchaseOrder.DataKeys[rowIndex]["purchaseOrderID"].ToString();
          if (currentCommand == "edit" || currentCommand == "new") {
              cs.RegisterStartupScript(this.GetType(), "popupScript", "window.open('PurchaseOrderDetail.aspx?purchaseOrderID=" + purchaseOrderID + "','_blank');", true);
          }
  </code></pre>
  
  <p>I also try to put grv_purchaseOrder.EditIndex = -1; in rowEditing event, but it doesn't do anything.</p>