62,073
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 给当前节点添加子节点
/// </summary>
/// <param name="node">当前节点</param>
/// <param name="pid">当前节点的ID</param>
protected void AddPages(TreeNode node, string pid)
{
DataSet ds = lm.GetPage(pid);
if (ds != null && ds.Tables.Count > 0)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
TreeNode childnode = new TreeNode();
childnode.Text = dr["BigPageName"].ToString();
childnode.NavigateUrl = "bbsSolution.aspx?PageId=" + dr["PageId"].ToString();
childnode.Target = "mainFrame";
//给当前节点添加子节点
AddPages(childnode, dr["PageId"].ToString());
if (node == null)
{
TreeView1.Nodes.Add(childnode);
}
else
{
node.ChildNodes.Add(childnode);
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<script src="jQuery/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="jQuery/Plugins/jquery-easyui-1.2.1/jquery.easyui.min.js" type="text/javascript"></script>
<link href="jQuery/Plugins/jquery-easyui-1.2.1/themes/icon.css" rel="stylesheet" type="text/css" />
<link href="jQuery/Plugins/jquery-easyui-1.2.1/themes/default/easyui.css" rel="stylesheet" type="text/css" />
<script src="jQuery/Plugins/jquery-easyui-1.2.1/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
<head runat="server">
<title></title>
</head>
<script type="text/javascript">
$(document).ready(function() {
$('#tt').tree();
});
</script>
<body >
<form id="form1" runat="server">
<ul id="tt">
<li>
<span>一级菜单</span>
<ul>
<li>
<span>二级菜单</span>
<ul>
<li><span>File 11</span></li>
<li><span>File 12</span></li>
<li><span>File 13</span></li>
</ul>
</li>
<li>
<span>二级菜单</span>
<ul>
<li><span>File 11</span></li>
<li><span>File 12</span></li>
<li><span>File 13</span></li>
</ul>
</li>
</ul>
</li>
<li>
<span>一级菜单</span>
<ul>
<li>
<span>二级菜单</span>
<ul>
<li><span>File 11</span></li>
<li><span>File 12</span></li>
<li><span>File 13</span></li>
</ul>
</li>
<li>
<span>二级菜单</span>
<ul>
<li><span>File 11</span></li>
<li><span>File 12</span></li>
<li><span>File 13</span></li>
</ul>
</li>
</ul>
</li>
</ul>
</form>
</body>
</html>