dropdownlist显示树形结构
/// <summary> /// 递归 /// </summary> /// <param name="deplist"></param> /// <param name="level">制表符分隔符</param> /// <param name="filterDepId">过滤的元素</param> /// <returns></returns> private static List<Department> GetDepList(List<Department> deplist, int level, int filterDepId) { string tempString = "├"; tempString = tempString.PadRight(level * 2, '─'); List<Department> newList = new List<Department>(); foreach (Department dep in deplist) { if (dep.DeptId == filterDepId) continue; Department newDep = new Department(); newDep.Name = tempString + dep.Name; newDep.DeptId = dep.DeptId; newList.Add(newDep); List<Department> children = new BLL.DepartmentMan().GetDepsByParentId(dep.DeptId); if (children.Count > 0) { newList.AddRange(GetDepList(children, level + 1, filterDepId)); } } return newList; }
生活没有输赢,不要在乎别人如何评价你,开心就好。
QQ群:158138959