title: Programmaticaly get gridview row out of edit mode
body: <p>In the <code>OnRowCommand</code> event of a ASP.NET gridview control, how can I programmaticaly get the row OUT of edit mode?
  I set the row to edit mode via a commandfield. After user clicks "Disapprove now" I want to set the row in 'regular' non-edit mode.</p>
  
  <p>I now have:</p>
  
  <pre><code>&lt;asp:TemplateField HeaderStyle-Width="100" HeaderText="Actions" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Center"&gt;
      &lt;ItemTemplate&gt;     
          &lt;asp:Literal ID="ltStatus" runat="server" /&gt;
          &lt;asp:LinkButton CssClass="btn-primary-green" CommandArgument="&lt;%# Container.DataItemIndex %&gt;" ID="btnApprove" CommandName="approve" runat="server" Text="Approve" /&gt;&lt;br /&gt;
          &lt;asp:LinkButton CssClass="btn-primary" CommandArgument="&lt;%# Container.DataItemIndex %&gt;" ID="btnDelete" Visible="false" CommandName="deleteorder" runat="server" Text="Delete" /&gt;                    
      &lt;/ItemTemplate&gt;
      &lt;EditItemTemplate&gt;
          &lt;asp:DropDownList ID="ddlDisApproveReason" ValidationGroup="disapprove" runat="server" &gt;
              &lt;asp:ListItem Text="&lt;%$Resources:disapprovereason %&gt;" Value="0" /&gt;
              &lt;asp:ListItem Text="&lt;%$Resources:duplicateorder %&gt;" Value="1" /&gt;
              &lt;asp:ListItem Text="&lt;%$Resources:testorder %&gt;" Value="2" /&gt;
              &lt;asp:ListItem Text="&lt;%$Resources:retourorder %&gt;" Value="3" /&gt;
          &lt;/asp:DropDownList&gt;
          &lt;asp:RequiredFieldValidator CssClass="errortext" ID="rfvDisapprove" InitialValue="0" ValidationGroup="disapprove" ControlToValidate="ddlDisApproveReason" runat="server" ErrorMessage="&lt;%$resources:glossary,required %&gt;" SetFocusOnError="true" Display="Dynamic" /&gt;
          &lt;asp:LinkButton CssClass="btn-primary" ValidationGroup="disapprove" CommandArgument="&lt;%# Container.DataItemIndex %&gt;" ID="btnDisApprove" CommandName="disapprove" runat="server" Text="Disapprove now" /&gt;                    
          &lt;br /&gt;
  
      &lt;/EditItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  &lt;asp:CommandField ShowEditButton="true" EditText="&lt;%$Resources:disapprove %&gt;" /&gt;
  </code></pre>
  
  <p>OnRowCommand Event</p>
  
  <pre><code>Protected Sub gvAllOrders_OnRowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Handles gvAllOrders.RowCommand 
      If e.CommandName = "disapprove" Then
          index = Convert.ToInt32(e.CommandArgument)
          data = gvAllOrders.DataKeys(index)
          orderId = data.Values("id")
          Dim clickedRow As GridViewRow = CType(CType(e.CommandSource, LinkButton).NamingContainer, GridViewRow)
          Dim reason As Integer = CType(clickedRow.FindControl("ddlDisApproveReason"), DropDownList).SelectedValue
  
          If GeneralFunctions.DisapproveOrder(False, reason, Date.Now, orderId) = 1 Then
              'disaprove order
              'HERE I WANT THE ROW TO GO OUT OF EDIT MODE
              gvAllOrders.DataBind()
          End If
      End If
  End Sub     
  </code></pre>