More in this section

Forums / Bugs & Issues / radmenu throwing ArgumentNull Exception

radmenu throwing ArgumentNull Exception

1 posts, 0 answered
  1. Surya CD
    Surya CD avatar
    57 posts
    Registered:
    06 Apr 2010
    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
     
    '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.
1 posts, 0 answered