title: GridView not changing to edit mode when EditIndex is set on RowEditing
body: <p>I am using Visual Studio 2010, VB.NET, target framework .NET 4.0.</p>
  
  <p>I have a GridView which I am binding to some object collection, with a CommandField column that should allow edit of the selected row.</p>
  
  <p>I am setting the EditIndex property correctly in the RowEditing eventhandler.</p>
  
  <p>The problem is: When I click the "Edit" link that is generated, nothing apparently happens, the row gets rendered again in "view mode", not "edit mode".</p>
  
  <p>But if I do some random postback, like clicking my "doNothing" button, the row gets rendered in "edit mode" in the next postback.</p>
  
  <p>I have managed to reproduce the problem in the following code:</p>
  
  <p>ASPX:</p>
  
  <pre><code>&lt;%@ Page Language="vb" AutoEventWireup="false" CodeBehind="MyForm.aspx.vb" Inherits="MySandBox.MyForm" %&gt;
  
  &lt;%@ Register Src="MyControl.ascx" TagName="MyControl" TagPrefix="uc1" %&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;asp:GridView ID="gvInfrator" runat="server" AutoGenerateColumns="false"&gt;
          &lt;Columns&gt;
              &lt;asp:CommandField ShowEditButton="true" /&gt;
              &lt;asp:BoundField HeaderText="MyField" DataField="MyField" /&gt;
          &lt;/Columns&gt;
      &lt;/asp:GridView&gt;
      &lt;asp:Button ID="btnDoNothing" runat="server" Text="Just do a postback" /&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Code Behind:</p>
  
  <pre><code>Public Class MyDto
      Public Property MyField As String
  End Class
  
  Public Class MyForm
      Inherits System.Web.UI.Page
  
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
          Me.BindMyData()
      End Sub
  
      Private Sub BindMyData()
          Dim myData As New MyDto
          myData.MyField = "My field value"
  
          Me.gvInfrator.DataSource = New MyDto() {myData}
          Me.gvInfrator.DataBind()
      End Sub
  
      Protected Sub gvInfrator_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gvInfrator.RowEditing
          Me.BindMyData() 
  
          Me.gvInfrator.EditIndex = e.NewEditIndex
      End Sub
  
  End Class
  </code></pre>
  
  <p>Am I doing something wrong? Is this a bug in .NET Framework 4? Is there any workaround?</p>