title: How do I use the RowCreated event for GridViews
body: <p><strong>Problem:</strong></p>
  
  <p>I want to add headers in the middle of a gridview databind. I updated the DataTable to include headers and their correct positions(I've checked during debug, they're there). On the new rows that contain headers, one of the unneeded fields (unneeded as in the header doesn't need that information) has a flag called "Subheader" in it.</p>
  
  <p><strong>Background information:</strong></p>
  
  <p>So my datatable rows hold a server name, and the group the server belongs to. I updated the DataTable so it inserts a new row where the server name is the header text. The server group that this new row belongs to is "Subheader". My datatable holds more information than what my gridview shows. My gridview only needs one column, but has a column with <code>visibility=false;</code> which holds the server group.</p>
  
  <p><strong>What I want to achieve:</strong></p>
  
  <p>So when I bind this datatable to the gridview I want all the non-header rows to be links that point to another location. All the data rows that are headers I want to just leave them as is.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>    private void CurrentServers_RowCreated(Object sender, GridViewRowEventArgs e)
      {
  
          if (e.Row.RowType == DataControlRowType.DataRow)
          {
              if(e.Row.Cells[1].Text != "Subheader")
              {
                  e.Row.Cells[0].Text = "&lt;a href='/EventViewer.aspx?m=" + e.Row.Cells[0].Text + "&amp;s=&amp;e=Application&amp;r=25'&gt;" + e.Row.Cells[0].Text + "&lt;/a&gt;";
              }
          }
  
      }
  </code></pre>
  
  <p><strong>Questions:</strong></p>
  
  <p>This isn't working. <code>e.Row.Cells[1].Text != "Subheader"</code> always returns true. In debugging I check the value of <code>e.Row.Cells[1].Text</code> and somewhere in there it has the information I need. </p>
  
  <ol>
  <li>Is this the correct event I should be handling?</li>
  <li>How do I access that data? <code>e.Row.Cells[1].Text</code> and <code>e.Row.Cells[1].ToString()</code> do not return the result that I want, even though when in debugging I can find the value I want in <code>e.Row</code></li>
  <li>I've tried finding exactly how this works but am unable to find answers. If my GridView only has columns for 2 datatable columns, will <code>e.Row.Cells</code> only have the 2 cells that my gridview requires, or does this take place before it breaks apart the datatable (i.e. does it have all the columns that my datatable has)</li>
  </ol>