/// <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(); } if (!string.IsNullOrEmpty(parentName)) { dic = cBll.GetKeyValueOnParentName(parentName); //只显示当前父级名称及其子节点的选择 if (dic != null && dic.Count > 0) { listControl.Items.Clear(); dic.Distinct(); } } else { dic = cBll.GetKeyValue("and ParentID='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); } } }
/// <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")); if (bll == null) { bll = new BLL.Category(); } Dictionary <string, string> dic = bll.GetKeyValue(" and ParentID='0' "); foreach (KeyValuePair <string, string> kvp in dic) { string name = kvp.Value; string value = kvp.Key; listControl.Items.Add(new ListItem(name, value)); CreateSubNode(listControl, value, name); } }