解决方案 »
- 如何在页面关闭时执行指定代码
- 直接封装好的验证码
- Application过期时间
- asp.net最主要的知识点是什么?
- 求助:谁有VS2005工具箱里面的控件介绍啊???我看不懂那些因为名称的控件,不知道是做什么用的?
- datagrid取值问题
- treeview问题,节点颜色用css控制,但是过段时间会自己变成蓝色,怎么回事?
- ACCESS中的图片显示和插入问题!!!感激不尽!
- saucer:关于DATAGRID 绑定dropdownlist的问题??????急
- 迎欢大家加入C#ASP.NET群 4510555。Microsoft!!
- 有谁弄过paypal支付,求有经验的看看,现在已经能支付了 但是没有返回post数据
- C# 调用API实现MP3播放
<asp:TreeView ID="TVSysFunUpdate" runat="server" Width="89px" Font-Size="Small">
</asp:TreeView>
public void DisplayUserMenu()
{ this.TVSysFunUpdate.Nodes.Clear(); //得到系统菜单表中所有的第一级菜单
DataSet ds = DbHelperSQL.Query("select * from dbo.shopClass where shopid=" + shopid + " and father=0 order by classorder");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{ //得到第一层节点的Id string nodeId = ds.Tables[0].Rows[i]["shopClassid"].ToString(); //得到第一层节点的显示名称 string displayName = ds.Tables[0].Rows[i]["shopClassname"].ToString(); //根据节点信息创建一层节点 TreeNode fatherNode = CreateTreeNode(displayName, nodeId, "images/up01.gif");
CreateChildTree(nodeId, fatherNode); this.TVSysFunUpdate.Nodes.Add(fatherNode); }
} private TreeNode CreateTreeNode(string strText, string strId, string strImage)
{ TreeNode newNode = new TreeNode(); newNode.Text = strText; newNode.Value = strId; newNode.ImageUrl = strImage; return newNode; } //创建第二级节点 public void CreateChildTree(string nodeId, TreeNode fatherNode)
{ //在三层下实现获得父级节点为nodeId的所有子节点
DataSet ds = DbHelperSQL.Query("select * from dbo.shopClass where shopClassid=" + nodeId + " order by classorder");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{ //得到第二层节点Id string childNodeId = ds.Tables[0].Rows[i]["shopClassid"].ToString(); //得到第二层节点的显示名称 string childDisplayName = ds.Tables[0].Rows[i]["shopClassname"].ToString();
//根据节点信息,创建第二层节点 TreeNode childNode = CreateTreeNode(childDisplayName, childNodeId, "images/up01.gif"); childNode.Target = ""; childNode.NavigateUrl = "shopGoodsSearch.aspx?ColId=" + childNodeId; //将子节点加入到父节点中 AddTree(fatherNode, childNode); } } //将子节点加入到父节点中 private void AddTree(TreeNode fatherNode, TreeNode childNode)
{ fatherNode.ChildNodes.Add(childNode); }
谢谢,不过只有一层节点。关键是Tree的行点击。