title: How to hide column in gridview while setting the data source
body: <p>I have following code to hide column and edit column header. But its not going into foreach. I have tried various method by putting the foreach into DataBound, RowDataBound, RowCreated events. But not working. </p>
  
  <pre><code>GridView1.AutoGenerateColumns = true;
  GridView1.DataSource = SomeObject[];
  GridView1.DataBind();
  
  foreach (DataControlField col in GridView1.Columns)
  {
      if (col.HeaderText == "FirstName") 
      {
          col.HeaderText = "First Name"; 
      }
      if (col.HeaderText == "SchoolName") 
      { 
          col.Visible = false; 
      }
  }
  </code></pre>
  
  <p>Can anyone please advice me the fix. Thanks</p>