c#无线循环出树形导航 ,可折叠,有勾选
2020-12-13 14:41
标签:折叠导航 树形导航 无线循环 输出结果 表结构 c# 代码: public string showdep()//输出第一层,根据所属上级id调用下一层 { string str = ""; DataTable dep = getdep(0, ""); int ii = 0; foreach (System.Data.DataRow dt1 in dep.Rows) { str += " str += " onClick=\"chkbm(" + ii + ",‘" + dt1["depid"].ToString() + " ‘)\" value=\"" + dt1["depid"].ToString() + "\"" + PowerCheck.Depsge(dt1["depid"].ToString()) + " />"; str += dt1["depName"].ToString(); str += " DataTable dep1 = getdep(int.Parse(dt1["depid"].ToString()), " |-"); str += showdep1(dep1, "|-"); ii++; } return str; } public DataTable getdep(int upid, string shu) {//shu字段 放在最前面输出 可看出层次, 但此次脚本已控制层次,so此次没用上 string sql = "select depid,depname,upid,‘" + shu + "‘ as shu from depart where upid=" + upid + " order by xh asc "; DataTable dt = dbc.spdataset(sql).Tables[0]; return dt; } public string showdep1( DataTable dt, string shu) { string str=""; if (dt.Rows.Count > 0) { shu = " " + shu; int ii = 0; str += " foreach (System.Data.DataRow dt1 in dt.Rows) { str += " str += " onClick=\"chkbm(" + ii + ",‘" + dt1["depid"].ToString() + " ‘)\" value=\"" + dt1["depid"].ToString() + "\"" + PowerCheck.Depsge(dt1["depid"].ToString()) + " />"; str += dt1["depName"].ToString(); str += " DataTable dep1 = getdep(int.Parse(dt1["depid"].ToString()), shu); str += showdep1(dep1, shu); ii++; } str += " } return str; } 前台html代码 引用树形折叠js, 把打钩项的id逗号分隔存到一个输入框里 方便后台读取 c#无线循环出树形导航 ,可折叠,有勾选 标签:折叠导航 树形导航 无线循环 原文地址:http://zhaoyingyatou.blog.51cto.com/7151735/1570372
depid
depname
upid//所属上级id
xh //排序 正序
123
一级导航
0 // 一级
0
124
一级下二级导航
123
1
";
";