Accessing control which is in ListView InsertItemTemplate
<p>I have a LinkButton in listview InsertItemTemplate. Whose visibility i want to set from code behind. I am using this code, but it seems on applying breakpoint that the control is not reaching InsertItemTemplate. It just stays within ItemTemplate. </p>

<pre><code>   protected void Page_Load(object sender, EventArgs e)
    {
        if(Session["UserId"].ToString() == Request.QueryString["Id"].ToString())
        {

            foreach (ListViewItem item in lvAlbums.InsertItem.Items)
            {
                LinkButton linkButton = item.FindControl("LinkButton1") as LinkButton;
                if (linkButton != null)
                    linkButton.Visible = false;
            }
        }
    }
</code></pre>

<p>Source code: </p>

<pre><code>&lt;form id="form1" runat="server"&gt;

    &lt;asp:ListView ID="lvAlbums" runat="server"
            DataSourceID="SqlDataSource1" GroupItemCount="3" 
            InsertItemPosition="LastItem"&gt;            
            &lt;LayoutTemplate&gt;                
                    &lt;table border="1"&gt;
                       &lt;tr ID="groupPlaceholder" runat="server"&gt;
                       &lt;/tr&gt;
                    &lt;/table&gt;                       
            &lt;/LayoutTemplate&gt;                                              
            &lt;GroupTemplate&gt;
                    &lt;tr&gt;
                        &lt;td ID="itemPlaceholder" runat="server"&gt;
                        &lt;/td&gt;
                    &lt;/tr&gt;
             &lt;/GroupTemplate&gt;             
             &lt;ItemTemplate&gt;
                    &lt;td id="Td3" width="150px" height="150px" align="center" style="background-color: #e8e8e8;color: #333333;"&gt;
                    &lt;asp:HiddenField ID="hfPhotoID" runat="server" Value='&lt;%# Eval("DefaultPhotID") %&gt;' /&gt;
                    &lt;a href='&lt;%# "Photos.aspx?AlbumID="+Eval("AlbumID") %&gt;'&gt; 
                    &lt;asp:Image CssClass="Timg" runat="server" ID="imPhoto" ImageUrl='&lt;%# "ThumbNail.ashx?ImURL="+Eval("Photo") %&gt;' /&gt;
                    &lt;/a&gt;
                    &lt;br /&gt;                    
                    &lt;b&gt;&lt;asp:Label ID="lblAlbumName" runat="server" Text='&lt;%# Eval("AlbumName") %&gt;'&gt;&lt;/asp:Label&gt;   &lt;/b&gt;
                    &lt;/td&gt;                
                &lt;/ItemTemplate&gt;

                &lt;InsertItemTemplate&gt;
                &lt;td id="Td3" width="150px" height="150px" runat="server" align="center" style="background-color: #e8e8e8;color: #333333;"&gt;
                    &lt;asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl="~/CreateAlbum.aspx"&gt; Create New Album1&lt;/asp:LinkButton&gt;
             &lt;%--   &lt;a href="CreateAlbum.aspx" id="createalbumlink" runat="server"&gt;                    
                    Create New Album
                &lt;/a&gt;--%&gt;
                &lt;/td&gt;              
                &lt;/InsertItemTemplate&gt;             
            &lt;/asp:ListView&gt;

        &amp;nbsp;&lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="&lt;%$ ConnectionStrings:SLIITComDBConnectionString %&gt;" 

        SelectCommand="SELECT Album.AlbumID, Album.DefaultPhotID, Album.AlbumName, PhotAlbum.Photo FROM Album INNER JOIN PhotAlbum ON Album.DefaultPhotID = PhotAlbum.PhotoID where album.userid=@userid"&gt;
       &lt;SelectParameters&gt;
       &lt;asp:QueryStringParameter Name="userid" Type="int32"  QueryStringField="id" /&gt;

         &lt;%--&lt;asp:SessionParameter Name="userid" Type="String"  SessionField="UserId" /&gt;--%&gt;
&lt;/SelectParameters&gt;
        &lt;/asp:SqlDataSource&gt;
    &lt;/form&gt;
</code></pre>
