title: All GridView rows disappear while selecting a row
body: <p>Please consider the values in comments which I got in debug mode:</p>
  
  <pre><code>protected void FilesGrid_SelectedIndexChanged(object sender, EventArgs e)
  {
      int selected = FilesGrid.SelectedIndex; // selected = 2
      FilesGrid.DataBind();  //added after feedback in comments. it makes no change
      int count = FilesGrid.Rows.Count; // count = 0
      GridViewRow row = FilesGrid.Rows[selected]; // row = null
      GridViewRow row0 = FilesGrid.Rows[0]; // row = null
  }
  </code></pre>
  
  <p>I came to this code while investigating why SelectedValue gives null in this event handler (the DataKeyNames parameter was set for sure).</p>
  
  <p>Can anybody explain how it is possible?</p>
  
  <p>Thank you in advance.</p>
  
  <p>PS.
  Here is my aspx code:</p>
  
  <pre><code>&lt;asp:GridView ID="FilesGrid" runat="server" AutoGenerateColumns="False" 
      AutoGenerateSelectButton="True"  
      onselectedindexchanged="FilesGrid_SelectedIndexChanged" 
      style="margin-top: 0px" &gt;
      &lt;Columns&gt;
          &lt;asp:CommandField ShowDeleteButton="True" /&gt;
          &lt;asp:BoundField DataField="Name" HeaderText="Name" /&gt;
          &lt;asp:BoundField DataField="Length" DataFormatString="{0:N0}" 
              HeaderText="Size in Bytes" HtmlEncode="False" /&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Here is how I bind data:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      if (!Page.IsPostBack)
      {
          string [] dd = {"FullName"};
          FilesGrid.DataKeyNames = dd;
  
          string appPath = Request.PhysicalApplicationPath; 
          DirectoryInfo dirInfo = new DirectoryInfo(appPath); 
          FileInfo[] files = dirInfo.GetFiles();
          FilesGrid.DataSource = files;
          FilesGrid.DataBind();            } 
  }
  </code></pre>