title: How to find a control located inside datalist itemtemplate, on a Page_Load event?
body: <p>I have a datalist which display's thumbnails of images and a download icon under it, when user clicks on the download icon, system download's the image at client's location.</p>
  
  <pre><code>&lt;asp:DataList ID="dtlSearchDetails" runat="server" OnItemCommand="dtlSearchDetails_ItemCommand" OnItemDataBound="dtlSearchDetails_ItemDataBound"&gt;
                              &lt;ItemTemplate&gt;
                                  &lt;asp:ImageButton runat="server" ID="dtlImageCol" ImageUrl='&lt;%# "~/uploads/thumbnails/" + Eval("ImageName") %&gt;' /&gt;&lt;br /&gt;
                                  &lt;asp:Label runat="server" ID="dtusage" Text='&lt;%# Eval("usage") %&gt;' Style="color: #CC121B;"&gt;&lt;/asp:Label&gt;&lt;br /&gt;
                                  &lt;asp:ImageButton runat="server" ID="dtlImgDownload" CommandName="dtlImgDownload" CommandArgument='&lt;%# Eval("ImageName") %&gt;' ImageUrl="images/download.png" style="height:20px; width:20px;"/&gt;&amp;nbsp;
                              &lt;/ItemTemplate&gt;
                          &lt;/asp:DataList&gt;
  </code></pre>
  
  <p>All works well just the problem is that datalist is wrapped inside updatepannel and hence in order to download image at user end I need to register the control on the Page_Load event :</p>
  
  <pre><code>ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(dtlImgDownload);
  </code></pre>
  
  <p>since the <code>dtlImgDownload</code> is inside the datalist, I always get an error <code>"The name dtlImgDownload doesn't exists in current context."</code></p>
  
  <p>I tried several ways to find the control like <code>dtlSearchDetails.FindControl("dtlImgDownload ")</code>
  but it always returns null.</p>
  
  <p>I also tried </p>
  
  <pre><code>if(dtlSearchDetails.FindControl("dtlImgDownload ") != null)
          {
              ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(dtlSearchDetails.FindControl("dtlImgDownload "));
          }
  </code></pre>
  
  <p>But same result, its always null.</p>
  
  <p>Kindly point me to the right direction.</p>