private void AppendChildren(Category parent, ref StringBuilder html) { string rootCss = ""; List <Category> childCategories; if (parent == null) { //childCategories = RootCategories; childCategories = CategoryCollection.GetTopLevelCategories(storeId, IncludeHiddenCategories); rootCss = CssClassForOuterList; } else { childCategories = parent.GetChildCategoriesInSortedOrder(IncludeHiddenCategories).ToList(); } if (childCategories.Count > 0) { html.AppendFormat("<{0}{1}>", containingElementTag, !string.IsNullOrEmpty(rootCss) ? " class=\"" + rootCss + "\"" : ""); foreach (Category child in childCategories) { html.AppendFormat(@"<{0} id=""{1}""{2}>{3}", itemElementTag, htmlPrefixCategoryId + child.Id, GetCategoryCssAttribute(child), GetCategoryName(child)); if (!MaxNestingLevel.HasValue || (child.NestingLevel.Value < MaxNestingLevel.Value)) { AppendChildren(child, ref html); } html.AppendFormat("</{0}>", itemElementTag); } html.AppendFormat("</{0}>", containingElementTag); } }