title: How do I change a cell value in an ASP.NET GridView based upon another cell value when the update button is clicked?
body: <p>I am trying to change a cell value in a <code>GridView</code> when a user edits another cell value in that <code>GridView</code>. Here is the <code>RowUpdating</code> function that I have tried: </p>
  
  <pre><code>Private Sub Gv_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles Gv.RowUpdating
          Dim Gvr As GridViewRow = DirectCast(sender.NamingContainer, GridViewRow)
          Dim lessonName As String = Gvr.Cells(2).Text
          Gvr.Cells(3).Text = GetLessonID(lessonName)
      End Sub
  </code></pre>
  
  <p>As you can see, I tried casting the naming container of the sender to a <code>GridViewRow</code>, but that doesn't work. I thought the naming container would be the <code>GridView</code> itself, but it is not. Basically, I need to know how to access the cell that needs to be automatically changed in the <code>RowUpdating</code> function. I should mention that the cell in question cannot be edited by the user; rather, it is updated automatically when the <code>Update</code> button is clicked. Any help is greatly appreciated. Please let me know if I can clarify anything. Thanks!</p>