This is a seperate solution for seperate problem you've asked in my first solution. A request please add seperate question for seperate problem it helps other to easily locate answer for similar problem.
Now the new problem you are facing:
if you apply XSL to the XML you are getting from ds.GetXml(); you will get below output:
="1.0"="utf-8"
<MenuItems>
<MenuItem Text="Category Name 1" ToolTip="" NavigateUrl="?Sel=" Text2="" Test3="" />
<MenuItem Text="Category Name 2" ToolTip="" NavigateUrl="?Sel=" Text2="" Test3="" />
<MenuItem Text="Category Name 3" ToolTip="" NavigateUrl="?Sel=" Text2="" Test3="" />
<MenuItem Text="Category Name 4" ToolTip="" NavigateUrl="?Sel=" Text2="" Test3="" />
<MenuItem Text="Category Name 5" ToolTip="" NavigateUrl="?Sel=" Text2="" Test3="" />
</MenuItems>
you do not have any tree-like XML for a tree-like menu, you should update your XSL to generate appropriate XML for XMLDatasource. I have updated the XSL a bit and you can modify it according to your app requirement.
XSL:
="1.0"="utf-8"
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes" encoding="utf-8"/>
<xsl:template match="/Menus">
<MenuItems>
<xsl:call-template name="MenuListing" />
</MenuItems>
</xsl:template>
<xsl:template name="MenuListing">
<xsl:apply-templates select="Menu" />
</xsl:template>
<xsl:template match="Menu">
<MenuItem>
<xsl:attribute name="Text">
<xsl:value-of select="CategoryName"/>
</xsl:attribute>
<xsl:attribute name="ToolTip">
<xsl:value-of select="Remarks"/>
</xsl:attribute>
<xsl:attribute name="NavigateUrl">
<xsl:text>?Sel=</xsl:text>
<xsl:value-of select="Text"/>
</xsl:attribute>
<xsl:call-template name="Menu"/>
<xsl:if test="count(Menu) >0">
<xsl:call-template name="MenuListing" />
</xsl:if>
</MenuItem>
</xsl:template>
<xsl:template name="Menu">
<xsl:apply-templates select="SubMenu" />
</xsl:template>
<xsl:template match="SubMenu">
<SubMenuItem>
<xsl:attribute name="Text">
<xsl:value-of select="SubCategoryName"/>
</xsl:attribute>
<xsl:attribute name="NavigateUrl">
<xsl:text>?Sel=</xsl:text>
<xsl:value-of select="Text"/>
</xsl:attribute>
<xsl:call-template name="SubMenu"/>
<xsl:if test="count(SubMenu) >0">
<xsl:call-template name="Menu" />
</xsl:if>
</SubMenuItem>
</xsl:template>
<xsl:template name="SubMenu">
<xsl:apply-templates select="SubSubMenu" />
</xsl:template>
<xsl:template match="SubSubMenu">
<SubSubMenuItem>
<xsl:attribute name="Text">
<xsl:value-of select="Sub2CategoryName"/>
</xsl:attribute>
<xsl:attribute name="NavigateUrl">
<xsl:text>?Sel=</xsl:text>
<xsl:value-of select="Text"/>
</xsl:attribute>
<xsl:if test="count(SubSubMenu) >0">
<xsl:call-template name="SubMenu" />
</xsl:if>
</SubSubMenuItem>
</xsl:template>
</xsl:stylesheet>
The above XSL will produce below result:
="1.0"="utf-8"
<MenuItems>
<MenuItem Text="Menu Item1" ToolTip="" NavigateUrl="?Sel=">
<SubMenuItem Text="Sub Menu Item1" NavigateUrl="?Sel=">
<SubSubMenuItem Text="Sub Sub Item1 " NavigateUrl="?Sel=" />
</SubMenuItem>
</MenuItem>
<MenuItem Text="Menu Item2" ToolTip="" NavigateUrl="?Sel=" />
<MenuItem Text="Menu Item3" ToolTip="" NavigateUrl="?Sel=" />
<MenuItem Text="Menu Item4" ToolTip="" NavigateUrl="?Sel=" />
<MenuItem Text="Menu Item5" ToolTip="" NavigateUrl="?Sel=" />
</MenuItems>
Now you need to update your DataItemBinding for Menu control:
<DataBindings>
<asp:MenuItemBinding DataMember="MenuItem" NavigateUrlField="NavigateUrl" TextField="Text" />
<asp:MenuItemBinding Depth="1" DataMember="SubMenuItem" NavigateUrlField="NavigateUrl" TextField="Text" />
<asp:MenuItemBinding Depth="2" DataMember="SubSubMenuItem" NavigateUrlField="NavigateUrl" TextField="Text" />
</DataBindings>
The Depth property extracts member from child node of datasource.
Hope it will help mark as answer if helped.
thanks,
Hemant