ASP.net How to hide a menu item from visitor?
<p>I want to hide the "Admin Panel" menu item from visitor, without going into the Role approach.</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" &gt;
    &lt;siteMapNode url="" title="Nav"  description=""&gt;
        &lt;siteMapNode url="~/Default.aspx" title="Home"  description=""&gt;&lt;/siteMapNode&gt;
        &lt;siteMapNode url="~/About.aspx" title="About"  description=""&gt;&lt;/siteMapNode&gt;
        &lt;siteMapNode url="" title="Admin Panel"  description=""&gt;
          &lt;siteMapNode url="~/Admin/AddPosts.aspx" title="Add Posts"  description=""&gt;&lt;/siteMapNode&gt;
          &lt;siteMapNode url="~/Admin/EditPosts.aspx" title="Edit Posts"  description=""&gt;&lt;/siteMapNode&gt;
          &lt;siteMapNode url="~/Admin/ApproveComments.aspx" title="Approve Comments"  description=""&gt;&lt;/siteMapNode&gt;
        &lt;/siteMapNode&gt;
    &lt;/siteMapNode&gt;
&lt;/siteMap&gt;
</code></pre>

<p>master page</p>

<pre><code>protected void Menu1_MenuItemDataBound(object sender, MenuEventArgs e)
{
    if (!HttpContext.Current.User.Identity.IsAuthenticated)
    {
        System.Web.UI.WebControls.Menu menu = (System.Web.UI.WebControls.Menu)sender;
        SiteMapNode mapNode = (SiteMapNode)e.Item.DataItem;

        System.Web.UI.WebControls.MenuItem itemToRemove = menu.FindItem(mapNode.Title);

        if (mapNode.Title == "Admin Panel")
        {
            System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
            if (parent != null)
            {
                parent.ChildItems.Remove(e.Item);
            }
        }
    }
}
</code></pre>

<p>markup</p>

<pre><code>    &lt;asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1" 
        Orientation="Horizontal" onmenuitemdatabound="Menu1_MenuItemDataBound"&gt;
    &lt;/asp:Menu&gt;
    &lt;asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" 
        ShowStartingNode="False" /&gt;
</code></pre>

<p>I tired the code above, but it is not working. It looks like, the parent for "Admin Panel" is null. But i don't know how to modify it to make it work.</p>

<p>I also tried a simply version:</p>

<pre><code>Menu1.Items.RemoveAt(2);
</code></pre>

<p>Not sure why it gave me index out of bound error. The Admin Panel item is really the 3rd item in Menu1 though.</p>

<p>Any help would be appreciated.</p>
