title: Can't Find Hyperlink of Cell during Gridview RowDatabound
body: <p>I have a gridview that lists rows of information from SQL. If the late column is set to 1 it should display the text of the row in red. This works, however the hyperlink text will not be displayed in red. So I'm trying to a) change the forecolor of the hyperlink element or b) apply a class to the element. When I try to retrieve the hyperlink it does not get it. When I retrieve a label it seems to work fine.</p>
  
  <p><strong>ASP</strong></p>
  
  <pre><code>&lt;asp:TemplateField HeaderText="Project"&gt;
        &lt;ItemTemplate&gt;
             &lt;a id="hlProject" href="VpnDetails.aspx?Project=&lt;%# Eval("id") %&gt;"&gt;&lt;%# Eval("project") %&gt;&lt;/a&gt;
         &lt;/ItemTemplate&gt;
   &lt;/asp:TemplateField&gt;
  &lt;asp:TemplateField HeaderText="Last Update"&gt;
         &lt;ItemTemplate&gt;
             &lt;asp:Label ID="lblLastUpdate" runat="server" Text='&lt;%#Eval("diff") %&gt;'&gt;&lt;/asp:Label&gt;
         &lt;/ItemTemplate&gt;
    &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p><strong>C#</strong></p>
  
  <pre><code>protected void gvLastIp_RowDataBound(object sender, GridViewRowEventArgs e)
      {
          if (e.Row.RowType == DataControlRowType.DataRow)
          {
              //Adds the tooltip to the last update label
              Label lblLastUpdate = e.Row.FindControl("lblLastUpdate") as Label;
              DateTime activeSince = Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, "begindate"));
              DateTime lastupdate = Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, "lastupdate"));
              lblLastUpdate.ToolTip = "Active Since " + activeSince.ToString("MMMM d yyyy HH:mm") + " - Last Update " + lastupdate.ToString("MMMM d yyyy HH:mm");
  
              if (Convert.ToString(DataBinder.Eval(e.Row.DataItem, "late")) == "1")
              {//if the row is late it should be red
                  e.Row.Font.Bold = true;
                  e.Row.ForeColor = System.Drawing.Color.Red;
  
                  HyperLink hlProject = new HyperLink();
                  try
                  {
                      hlProject = (HyperLink)e.Row.FindControl("hlProject");
                      hlProject.Attributes.Add("class", "late");
                      hlProject.ForeColor = System.Drawing.Color.Red;
                  }
                  catch (Exception e1)
                  {
                      lblError.Text = e1.Message;
                  }
              }
          }
  </code></pre>
  
  <p>So I need to know why it works for the label and not for the hyperlink. I also need a solution for the hyperlink.</p>