title: ASP.NET GridView header row text empty when AllowSorting enabled
body: <p>I am solving interesting problem. I have a gridview in my application and after button click (in OnClick event) I am trying to get selected row and header row.</p>
  
  <p>All worked fine when the grid was not sortable (AllowSorting="false"). This is the way how I access the header row cells:</p>
  
  <pre><code>GridViewControl.HeaderRow.Cells[idx].Text
  </code></pre>
  
  <p>But, once I switched on sorting (AllowSorting="True"), this approach does not work. Header row is created, expression GridViewControl.HeaderRow.Cells.Count returns the correct number of columns, but GridViewControl.HeaderRow.Cells[idx].Text property is always EMPTY! Nevertheless, on the page the grid view is displayed correctly including header column texts ...</p>
  
  <p>I have tried to find the answer on the web but without success ... I have found some similar questions but never answered ... so, does anybody know how to get header row column texts when sorting is enabled?</p>
  
  <p>Thank you in advance.</p>
  
  <p>PS: Do not advice me using of</p>
  
  <pre><code>GridVewControl.Columns[idx].Text
  </code></pre>
  
  <p>property ... there are just 2 columns with Edit &amp; Select commands ... rest columns are automatically generated.</p>