private void ToIndentedList(List <RadComboBoxItem> hierarchicalList, List <Category> categories, Category parentCategory, int level)
        {
            foreach (var category in categories.Where(c => parentCategory == null ? c.ParentId == null : c.ParentId == parentCategory.Id))
            {
                var listItemText = string.IsNullOrEmpty(category.Name)
                                       ? this.Localize("DefaultCategory.Text", this.LocalSharedResourceFile)
                                       : level > 0 ? " " + category.Name : category.Name;
                var listItemValue = category.Id.ToString(CultureInfo.InvariantCulture);

                RadComboBoxItem listItem = null;
                try
                {
                    listItem = new RadComboBoxItem(listItemText, listItemValue);

                    if (level > 0)
                    {
                        var pad = string.IsNullOrEmpty(this.Localize("Indent.Text")) ? '>' : this.Localize("Indent.Text")[0];
                        listItem.Text = listItem.Text.PadLeft(listItem.Text.Length + level, pad);
                    }

                    hierarchicalList.Add(listItem);
                }
                catch
                {
                    if (listItem != null)
                    {
                        listItem.Dispose();
                    }

                    throw;
                }

                var categoryId = category.Id;
                if (categories.ToList().Any(c => c.ParentId == categoryId))
                {
                    this.ToIndentedList(hierarchicalList, categories, category, level + 1);
                }
            }
        }
        private void ToIndentedList(List<RadComboBoxItem> hierarchicalList, List<Category> categories, Category parentCategory, int level)
        {
            foreach (var category in categories.Where(c => parentCategory == null ? c.ParentId == null : c.ParentId == parentCategory.Id))
            {
                var listItemText = string.IsNullOrEmpty(category.Name)
                                       ? this.Localize("DefaultCategory.Text", this.LocalSharedResourceFile)
                                       : level > 0 ? " " + category.Name : category.Name;
                var listItemValue = category.Id.ToString(CultureInfo.InvariantCulture);

                RadComboBoxItem listItem = null;
                try
                {
                    listItem = new RadComboBoxItem(listItemText, listItemValue);

                    if (level > 0)
                    {
                        var pad = string.IsNullOrEmpty(this.Localize("Indent.Text")) ? '>' : this.Localize("Indent.Text")[0];
                        listItem.Text = listItem.Text.PadLeft(listItem.Text.Length + level, pad);
                    }

                    hierarchicalList.Add(listItem);
                }
                catch
                {
                    if (listItem != null)
                    {
                        listItem.Dispose();
                    }

                    throw;
                }

                var categoryId = category.Id;
                if (categories.ToList().Any(c => c.ParentId == categoryId))
                {
                    this.ToIndentedList(hierarchicalList, categories, category, level + 1);
                }
            }
        }