Why NextSibling and PreviousSibling of CurrentNode getting Null

1 posts, 0 answers
  1. Surya CD
    Surya CD avatar
    18 posts
    Member since:
    Apr 2010

    Posted 03 Jul 2012 Link to this post

    Hi,
    In our project the menu is done using the telerik radmenu. For some pages that are not shown in navigation, it is throwing an exception.

    The website id done using the cms Sitefinity.

    'SiteMap.CurrentNode.NextSibling' threw an exception of type 'System.ArgumentNullException' System.Web.SiteMapNode {System.ArgumentNullException}.
    It is the same error with PreviousSibling.


    public void HorizontalRadMenu_ItemDataBound(object sender, RadMenuEventArgs e)
    {
    string[] strNavigationPages = { "Home", "About", "Product", "Sales", "Marketing", "Partners", "Resources", "...", "...", "...", "...", "...", "..." };
    if (e.Item != null)
    {
     
     
    if (e.Item.Level == 0)
    {
    parentPageId = ((Telerik.Sitefinity.Web.PageSiteNode)(e.Item.DataItem)).Id.ToString();
    }
     
     
     
     
    string currentPageId = ((Telerik.Sitefinity.Web.PageSiteNode)(e.Item.DataItem)).Id.ToString();
    string findThisString = e.Item.Text;
     
     
     
     
    int strIndex = -1;
    int flag = -1;
    if (!String.IsNullOrEmpty(findThisString) && ((Telerik.Sitefinity.Web.PageSiteNode)(e.Item.DataItem)).ShowInNavigation)
    {
    for (int strNumber = 0; strNumber < strNavigationPages.Length; strNumber++)
    {
    strIndex = strNavigationPages[strNumber].IndexOf(findThisString);
    if (strIndex > -1)
    {
    flag = 1;
    }
    }
     
     
    if (flag == -1 && ((Telerik.Sitefinity.Web.PageSiteNode)(e.Item.DataItem)).ParentKey != parentPageId && e.Item.Level < 2)
    {
    e.Item.Remove();
    }
    }
    else
    {
    e.Item.Remove();
    }
     
     
    }
    }



    When does the SiteMap.CurrentNode.NextSibling and the PreviousSibling becomes null? 
    Can anyone please help me.


    Thanks,
    Surya.
Back to Top