title: GridView Column.Count is always 0 after databind with a datatable
body: <p>I am trying to show/hide GridView columns conditionally.</p>
  
  <p>I am creating a dynamic DataTable and then Binding it to the GridView</p>
  
  <p>Later, on a post back, I am checking condition and want to show/hide a few columns of the GridView, but Column.Count is alway 0!</p>
  
  <p>The code I have is as below -
  ASPX page</p>
  
  <pre><code>&lt;asp:GridView ID="GridView1" runat="server"&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>.CS Page</p>
  
  <pre><code> protected void Button1_Click(object sender, EventArgs e)
  {
     DataTable aDT = new DataTable()
     aDT = createDataTable();   //datatable has 21 columns
  
     GridView1.DataSource = aDT;
     GridView1.DataBind();
  
     int temp = GridView1.Columns.Count;   //always 0
  }
  </code></pre>
  
  <p>Not sure what is wrong with the code</p>