I have this structure of List
, to be specific it is a \"CategoryItem\" Object. Here\'s my declaration of \"CategoryItem\" Object.
You need to create a recursive Method that "renders" a category item. This methods needs to be aware of the level or current depth in order render to correct indenting:
private void RenderCategory(HtmlTextWriter writer, CategoryItem item, int level)
{
writer.Write("- {1}
",
level * 5,
HttpUtility.HtmlEncode(item.Name));
int nextLevel = ++level;
foreach (CategoryItem child in item.SubCategories)
{
RenderCategory(writer, child, nextLevel);
}
}