title: Need help using C# FindControl
body: <p>I have a repeater inside a panel.<br>
  Inside this repeater I have another panel.Upon certain conditions, I want to set this <code>panel.visibility = false</code>.</p>
  
  <p>In the code behind, I try locating the panels on <code>OnItemDataBound</code> and set visible=false.  But it only returns <code>Object reference not set to an instance of an object.</code>. I guesing it's because it can't locate the panel.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    &lt;asp:Panel ID="Panel1" runat="server"&gt;
          &lt;asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="repComments_OnDataBound"&gt;    
               &lt;ItemTemplate&gt;                         
                  &lt;div&gt;
                     &lt;asp:Panel runat="server" ID="commentAdminPanel" CssClass="floatRight" &gt;
                       &lt;img id='deleteComment' class='deleteComment' src='/img/delete1.jpg' /&gt;  
                     &lt;/asp:Panel&gt;                     
                  &lt;/div&gt;
                &lt;/div&gt;
              &lt;/ItemTemplate&gt;
           &lt;/asp:Repeater&gt;
       &lt;/asp:Panel&gt;
  </code></pre>
  
  <p>And here is my code behind:</p>
  
  <pre><code>    protected void repComments_OnDataBound(Object sender, RepeaterItemEventArgs e)
      {
          Panel panel = (Panel)Repeater1.FindControl("commentAdminPanel");
          panel.Visible = false;
      }
  </code></pre>
  
  <p>What am I doing wrong?</p>