Exemplo n.º 1
0
        /// <summary>
        /// 绑定父级分类
        /// </summary>
        /// <param name="listControl"></param>
        private void InitCategoryList(ListControl listControl)
        {
            if (listControl.Items.Count > 0)
            {
                listControl.Items.Clear();
            }

            listControl.Items.Add(new ListItem("请选择", "0"));

            Dictionary <string, string> dic = null;

            if (cBll == null)
            {
                cBll = new BLL.Category();
            }

            dic = cBll.GetKeyValueByParentName("所有分类");

            if (dic != null && dic.Count > 0)
            {
                foreach (KeyValuePair <string, string> kvp in dic)
                {
                    ListItem li = null;
                    li = ddlCategory.Items.FindByValue(kvp.Key);
                    if (li == null)
                    {
                        string name  = kvp.Value;
                        string value = kvp.Key;
                        listControl.Items.Add(new ListItem(name, value));
                        CreateSubNode(listControl, value, name);
                    }
                }
            }
        }