title: Get a hidden grid view column, cell value on a selected row c#
body: <p>I have a client id column in my grid view, which i would prefer to stay hidden or un-editable. </p>
  
  <p>when the row of the gridview is being updated i would like to check if the value of a field is being changed to a certain value so i can time stamp in my database. </p>
  
  <p>Here is a copy of my function. </p>
  
  <pre><code> protected void gridStock_RowUpdating(object sender, GridViewUpdateEventArgs e)
      {
          String anotherUpdatedItem = e.NewValues[8].ToString();
          string oldValue = e.OldValues[7].ToString();
  
          string idValue = gridStock.DataKeys[0].Values["StockID"].ToString();
  
          anotherUpdatedItem.ToString();
  
          if (anotherUpdatedItem == "True" &amp;&amp; oldValue != "True")
          {
              string date = DateTime.Today.ToString();
  
              String str = "UPDATE Stock SET [DateSold]=@todaysDate WHERE StockID=@id";
  
              SqlCommand xp = new SqlCommand(str, vid);
              xp.Parameters.Add("@todaysDate", SqlDbType.Date).Value = date;
              xp.Parameters.Add("@id", SqlDbType.Int).Value = idValue;
  
              vid.Open();
  
              xp.ExecuteNonQuery();
              SqlDataAdapter da = new SqlDataAdapter();
              da.SelectCommand = xp;
  
              DataSet ds = new DataSet();
              da.Fill(ds, "ClientID");
  
              vid.Close();
          }
      }
  </code></pre>
  
  <p>As you can see i have added a datakey to the gridview, this also works but it only retrieves index 0 point. I need to get the stockid value of the row which has been clicked on to be able to pass it through my sql query. </p>
  
  <p>Could any one please help?</p>