title: Why is FindControl not working with my repeater?
body: <p>I'm trying to change the visibility of a pair of server controls (specifically a LinkButton and Label) that are nested inside the ItemTemplate part of a repeater during the onclick event of the same LinkButton.  I've actually already found a solution, but I don't understand why it works and not the way I was trying before.  What I was trying originally is as follows:</p>
  
  <p>Nested inside the ItemTemplate of a repeater</p>
  
  <pre><code>&lt;asp:LinkButton ID="lnAdd" CommandArgument='&lt;%#Eval("index") %&gt;' runat="server" Text="Add" OnClick="lnAdd_Click"&gt; &lt;/asp:LinkButton&gt;
  
  &lt;asp:Label Visible="false" runat="server" ID="videoAdded" Text="Video Added"&gt;&lt;/asp:Label&gt;
  </code></pre>
  
  <p>Then inside of that lnAdd_Click function I have:</p>
  
  <pre><code>Repeater1.FindControl("lnAdd").Visible = false;
  Repeater1.FindControl("videoAdded").Visible = true;
  </code></pre>
  
  <p>where Repeater1 is the id of the repeater these controls are in.  This appears to do nothing (though it compiles).  I assume this is because for some unknown reason those controls are not found.</p>
  
  <p>What does work is the last answer of the following question: <a href="https://stackoverflow.com/questions/1191034/server-controls-in-an-asp-net-repeater">Server controls in an asp.net repeater</a></p>
  
  <p>The solution appears to be doing something very similar what I've tried to do.  Its even using FindControl on a repeater.  The only difference (that I can see) is that it obtains the repeater via the sender object.  Hmmm, actually, now that I think about it the id of the elements are changed by .Net to some nonesense like <code>ctl00_ContentPlaceHolder1_Repeater1_ctl02_lnAdd</code> when this is actually run, so perhaps that's why its not finding it.  But at the same time, in the working solution I just give the normal ID like "lnAdd".  Is .Net automatically translating it?  Why would it do it for this solution and not for how I was trying to do it originally?</p>
  
  <p>Anyway, I feel like there's something fundamental here that I'm not quite grasping and would appreciate some enlightenment :D</p>