I have a parent datalist

inside the parent <selecteditemtemplate> are two child datalists

I can click on a linkbutton in the first child datalist ( it makes child 2 datalist visible)

once the child 2 datalist is visible, I click on a linkbutton inside child 2 and it (for some reason) makes the parent <selectedItemTemplate> close.


I cannot figure out for the life of me why:

the parent <selecteditemtemplate> doesnt close if I click a link in child 1
but parent <selecteditemtemplate> closes if I click a link in child 2?

Hope someone can Help, it would be much appreciated!!


heres the code:

Code:
Sub selectedsub1( sender As Object, e As DataListCommandEventArgs )
	
		If e.CommandName = "clickedsub1" Then
			Dim listsub1 as string = ctype(e.item.findcontrol("listsub1"), label).text
			ctype(e.item.findcontrol("Sub2DL"), datalist).visible = true
			ctype(e.item.findcontrol("sub1butt"), linkbutton).visible = false
			ctype(e.item.findcontrol("sub1butt2"), linkbutton).visible = true
			ctype(e.item.findcontrol("Sub1Folder"), image).ImageUrl="../Images/openfolder.jpg"
			sub2.text = "" 
			sub1.text = listsub1
			
		End If
		
		If e.CommandName = "clicked2sub1" Then
			ctype(e.item.findcontrol("Sub2DL"), datalist).visible = false
			ctype(e.item.findcontrol("sub1butt"), linkbutton).visible = true
			ctype(e.item.findcontrol("sub1butt2"), linkbutton).visible = false
			ctype(e.item.findcontrol("Sub1Folder"), image).ImageUrl="../Images/closedfolder.jpg"
			sub2.text = "" 
			sub1.text = ""
		End If
		
		If e.CommandName = "clickedsub2" Then 
		Dim listsub2 as string = ctype(e.item.findcontrol("listsub2"), label).text
			ctype(e.item.findcontrol("sub2butt"), linkbutton).visible = false
			ctype(e.item.findcontrol("sub2butt2"), linkbutton).visible = true
			ctype(e.item.findcontrol("Sub2Folder"), image).ImageUrl="../Images/openfolder.jpg"
			sub2.text = listsub2
		End If
		
		If e.CommandName = "clicked2sub2" Then 
		Dim listsub2 as string = ctype(e.item.findcontrol("listsub2"), label).text
			ctype(e.item.findcontrol("sub2butt"), linkbutton).visible = true
			ctype(e.item.findcontrol("sub2butt2"), linkbutton).visible = false
			ctype(e.item.findcontrol("Sub2Folder"), image).ImageUrl="../Images/closedfolder.jpg"
			sub2.text = listsub2
		End If
	
End Sub
and heres the html:

Code:
<asp:DataList ID="CatsDL" OnItemCommand="selectedcat"  DataKeyField="CatID" runat="server">
	<itemtemplate>
		<asp:Image ImageUrl="../Images/closedfolder.jpg" runat="server" />
		<asp:LinkButton  CommandName="clicked" Text='<%# DataBinder.Eval(Container.DataItem, "CatName") %>' runat="server" />
    </itemtemplate>
    <selecteditemtemplate><asp:Image ImageUrl="../Images/openfolder.jpg" runat="server" />
		<asp:LinkButton CommandName="clicked2" runat="server" CssClass="bbold" Text='<%# DataBinder.Eval(Container.DataItem, "CatName") %>' /><br>
		
		<asp:DataList DataKeyField="ID" ID="Sub1DL" OnItemCommand="selectedsub1" DataSource='<%# GetChildRelation(Container.dataitem, "Catagory_to_Sub1")%>' runat="server">
        	<itemtemplate>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="25">&nbsp;</td>
              			<td>
							<asp:Image ID="Sub1Folder" ImageUrl="../Images/closedfolder.jpg" runat="server" />
							<asp:Label ID="listsub1" Visible="false" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Sub1ID") %>' />
							<asp:LinkButton ID="sub1butt" CommandName="clickedsub1" Text='<%# DataBinder.Eval(Container.DataItem, "Sub1Name") %>' runat="server" />
							<asp:LinkButton Visible="false" ID="sub1butt2" CssClass="bbold" CommandName="clicked2sub1" Text='<%# DataBinder.Eval(Container.DataItem, "Sub1Name") %>' runat="server" />
				
		<asp:DataList Visible="false" OnItemCommand="selectedsub1" ID="Sub2DL" DataSource='<%# GetChildRelation(Container.dataitem, "Sub1_to_Sub2")%>' runat="server">
			<itemtemplate>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="25">&nbsp;</td>
						<td>
						  <asp:Image ID="Sub2Folder" ImageUrl="../Images/closedfolder.jpg" runat="server" />
						  <asp:Label ID="listsub2" Visible="false" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Sub2ID") %>' />
						  <asp:LinkButton ID="sub2butt" CommandName="clickedsub2"  Text='<%# DataBinder.Eval(Container.DataItem, "Sub2Name") %>' runat="server" /> <asp:LinkButton Visible="false" ID="sub2butt2" CssClass="bbold" CommandName="clicked2sub2"  Text='<%# DataBinder.Eval(Container.DataItem, "Sub2Name") %>' runat="server" />                       </td>
					</tr>
				</table>
			</itemtemplate>
			
		</asp:DataList>
              			</td>
            		</tr>
          		</table>
        	</itemtemplate>
      	</asp:DataList>
		
    </selecteditemtemplate>
	
</asp:DataList>