title: Datagrid row not being read code
body: <p>I have the following code...</p>
  
  <pre><code> Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.RowUpdating
       Dim SocioNumInfo As Integer = CInt(GridView1.Rows(GridView1.SelectedIndex).Cells(4).Text)
       MsgBox(SocioNumInfo.ToString)
       ...
   End Sub
  </code></pre>
  
  <p>Now, this code should read the cell, but it gives me the following error:</p>
  
  <p>Index was out of range. Must be non-negative and less than the size of the collection.
  Parameter name: index</p>
  
  <p>The MsgBox is just there for me to check if the data is being read, at the end of the day it should turn that into a parameter so I can add to the DB... but still.. nope nothing. Is that the correct code to read directly from a cell in a choosen row? In the "Protected Sub" area I already tried SelectedIndexChanging and RowEditing, etc... and still nothing. Still throws the error at me.</p>
  
  <p>If I try
  <code>Dim SocioNumInfo As String = CStr(GridView1.Rows(GridView1.SelectedRow).Cells(4).Text)</code> it gives me a "cannot be converted to Integer" error.</p>