Пример #1
0
        public override int GetHashCode()
        {
            int hash = GetType().GetHashCode();

            hash = (hash * 397) ^ RootCategoryId.GetHashCode();
            hash = (hash * 397) ^ ImageId.GetHashCode();

            return(hash);
        }
    /// <summary>
    /// DataBinds the control.
    /// </summary>
    public void ReloadData()
    {
        DisabledItems = string.Empty;
        drpCategories.Items.Clear();
        int shift = -1;

        string where = string.Empty;
        if (DisplayOnlyCategories)
        {
            // Only categories that are not marked as groups will be displayed
            where += "ISNULL([CategoryIsGroup], 0) = 0";
        }
        if (!string.IsNullOrEmpty(WhereCondition))
        {
            // Append additional WHERE condition
            where += " AND " + WhereCondition;
        }

        // Add root category item if needed
        if (IncludeRootCategory)
        {
            SettingsCategoryInfo rootCat = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(RootCategoryId);
            if (rootCat != null)
            {
                ListItem item = new ListItem();
                item.Text  = GetPrefix(shift) + ResHelper.LocalizeString(rootCat.CategoryDisplayName);
                item.Value = RootCategoryId.ToString();
                drpCategories.Items.Add(item);
                DisableItemInKeyEdit(item, rootCat.CategoryIsGroup);


                // Increase indent
                shift++;
            }
        }
        DataSet ds = SettingsCategoryInfoProvider.GetSettingsCategories(where, "CategoryOrder", 0, "CategoryID, CategoryParentID, CategoryName, CategoryDisplayName, CategoryOrder, CategoryIsGroup");

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            groupedDS = new GroupedDataSource(ds, "CategoryParentID");
            FillDropDownList(shift, RootCategoryId);
        }
    }