title: Hiding a GridView ID column
body: <p>Seems to be a common issue.</p>
  
  <p>I'm trying to hide a column of my GridView. I have read that simply setting the column to 'visible = false' will not work as I'm auto-generating my data.</p>
  
  <p>Currently my code stands as so:</p>
  
  <pre><code> protected void Page_Load(object sender, EventArgs e)
      {
          bind();
  
          if (GridView1.Columns.Count &gt; 0)
              GridView1.Columns[0].Visible = false;
          else
          {
              GridView1.HeaderRow.Cells[0].Visible = false;
              foreach (GridViewRow gvr in GridView1.Rows)
              {
                  gvr.Cells[1].Visible = false;
              }
          }
  
      }
  </code></pre>
  
  <p>The 'if' statement will not trigger as as said I am auto-generating the data. With the above loop, I can hide the header text of the column but want to hide the whole column with the ability to still be able to access the hidden data.</p>