title: ASP VB.NET GridView: Change Column cell text by column header name with AutogenerateColumn = True
body: <p>Pulling my hair out, some help would be great.</p>
  
  <p>I'm loading a GridView in ASP dynamically populating the results from an SQL Statement.  This page is for general queries so header names are pulled from the query results, no template.</p>
  
  <p>What I'm trying to do is when a header is called i.e.. SSN (sensitive data column) I want to go through each cell in this specific column and mask the field.  Example: "###-##-####". before the page is displayed, and so all changes are kept on each page change and when the GridView is re-binded.</p>
  
  <p>I looked over a couple events like GridView1_RowCreated, GridView1_OnDataBound</p>
  
  <p>However, whenever I search for the header.text it's always empty! I can change it and set it, but it's never populated in these events. This leads me to believe I’m looking in the wrong place to do this update.</p>
  
  <p>ie:</p>
  
  <pre><code>Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
  
      Dim header As String
  
      ' DataControlRowType.DataRow - also tried this with checking HeaderText too.
      If e.Row.RowType = DataControlRowType.Header Then
  
          For columnIndex As Integer = 0 To e.Row.Cells.Count - 1 Step 1
              header = e.Row.Cells(columnIndex).Text                
              Response.Write(header) ' Empty
              Response.Write("Cell") ' Will Display this for each header cell. 
              header = String.Empty         
          Next
  
      End If
  
  End Sub
  </code></pre>
  
  <p>Would I need to do this on the Page_Load or PreRender?  Any ideas/examples would be great.<br>
  Thanks for your help.</p>