TreeView 用法(有代码)(asp.net)_javascript技巧
程序员文章站
2022-03-28 18:30:01
...
前台代码
后台代码:
private void BindGrid()
{
DataTable mytable = menuTableBll.GetAllList().Tables[0]; //获取数据
CreateTree(mytable, TreeView1.Nodes, "0");
}
private void CreateTree(DataTable dtNodeSets, TreeNodeCollection node, string parent_id)
{
DataView dvList = new DataView(dtNodeSets);
dvList.RowFilter = "MeunParentId =" + parent_id;
TreeNode nodeTemp;
foreach (DataRowView dv in dvList)
{
nodeTemp = new TreeNode();
nodeTemp.Text = dv["MenuName"].ToString();
nodeTemp.Expanded = true;
nodeTemp.ToolTip = dv["MeunId"].ToString();
node.Add(nodeTemp);
CreateTree(dtNodeSets, nodeTemp.ChildNodes, dv["MeunId"].ToString());
}
}
复制代码 代码如下:
后台代码:
复制代码 代码如下:
private void BindGrid()
{
DataTable mytable = menuTableBll.GetAllList().Tables[0]; //获取数据
CreateTree(mytable, TreeView1.Nodes, "0");
}
private void CreateTree(DataTable dtNodeSets, TreeNodeCollection node, string parent_id)
{
DataView dvList = new DataView(dtNodeSets);
dvList.RowFilter = "MeunParentId =" + parent_id;
TreeNode nodeTemp;
foreach (DataRowView dv in dvList)
{
nodeTemp = new TreeNode();
nodeTemp.Text = dv["MenuName"].ToString();
nodeTemp.Expanded = true;
nodeTemp.ToolTip = dv["MeunId"].ToString();
node.Add(nodeTemp);
CreateTree(dtNodeSets, nodeTemp.ChildNodes, dv["MeunId"].ToString());
}
}
推荐阅读
-
有提示确定与取消功能的弹出式窗的代码_javascript技巧
-
js根据给定的日期计算当月有多少天实现思路及代码_javascript技巧
-
js仿百度有啊通栏展示效果实现代码_javascript技巧
-
javascript实现TreeView 无刷新展开的实例代码_javascript技巧
-
TreeView 用法(有代码)(asp.net)_javascript技巧
-
JS控件ASP.NET的treeview控件全选或者取消(示例代码)_javascript技巧
-
javascript 异步页面查询实现代码(asp.net)_javascript技巧
-
动态加载dtree.js树treeview(示例代码)_javascript技巧
-
动态加载dtree.js树treeview(示例代码)_javascript技巧
-
js实现简单的购物车有图有代码_javascript技巧