title: How do I access a control in the HeaderTemplate of my GridView
body: <p>I want to have a DropDownList in the header of my GridView. In My codebehind I can't seem to access it. Here is the HeaderTemplate:</p>
  
  <pre><code>&lt;asp:TemplateField SortExpression="EXCEPTION_TYPE"&gt;
      &lt;HeaderTemplate&gt;
          &lt;asp:Label ID="TypeId" runat="server" Text="Type" &gt;&lt;/asp:Label&gt;
          &lt;asp:DropDownList ID="TypeFilter" runat="server" AutoPostBack="true"&gt;
          &lt;/asp:DropDownList&gt;
      &lt;/HeaderTemplate&gt;
      ...
  &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>And here is the section in the code behind where I am trying to access the control 'TypeFilter'.</p>
  
  <pre><code>protected void ObjectDataSource1_Selected(object sender, 
                                            ObjectDataSourceStatusEventArgs e)
  {
      DataTable dt = (DataTable)e.ReturnValue;
      int NumberOfRows = dt.Rows.Count;
      TotalCount.Text = NumberOfRows.ToString();
      DataView dv = new DataView(dt);
      DataTable types = dv.ToTable(true, new string[] { "EXCEPTION_TYPE" });
      DropDownList typeFilter = (DropDownList)GridView1.FindControl("TypeFilter");
      typeFilter.DataSource = types;
      typeFilter.DataBind();
  
  }
  </code></pre>
  
  <p>You will notice that I am trying to use FindControl to get a reference to the DropDownList Control. This call returns null instead of returning the control. How do I get access to the control?</p>