title: asp .net How to hide a TemplateField of a gridview column but still access its value
body: <p>I have a datagridview which is loaded through a strored procedure. It has an ID column which i want to hide it but still access its value. I set the dataKeyNames and i have a method </p>
  
  <pre><code>     protected void grdTime_OnDataBound(object sender,EventArgs e)
      {
          grdTime.Columns[1].Visible = false;
      }
  </code></pre>
  
  <p>which i am trying to hide this column but i get the following error. If i remove the line inside the method it works. Here is the error.
  Index was out of range. Must be non-negative and less than the size of the collection.
  Parameter name: index</p>