日期:2014-05-18 浏览次数:20444 次
/// <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); } } } }
------解决方案--------------------
HTML
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Left.aspx.cs" Inherits="Left" %> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Untitled Page</title> <script language="javascript"> function chkAll() { //debugger; var chkall= document.all["chkall"]; var chkother= document.getElementsByTagName("input"); for (var i=0;i<chkother.length;i++) { if( chkother[i].type=='checkbox') { if(chkother[i].id.indexOf('TreeView1')>-1) { if(chkall.checked==true) { chkother[i].checked=true; } else { chkother[i].checked=false; } } } } } </script> </head> <body> <form id="form1" runat="server"> <table width=100% height=100%> <tr height=10> <td><input id="chkall" type="checkbox" onclick="chkAll();" />全选/取消</td> <td><asp:Button ID="Button1" runat="server" Text="Button" /></td> </tr> <tr valign=top> <td><asp:TreeView ID="TreeView1" runat="server" ></asp:TreeView></td> <td><iframe id=fMain style="BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none" src="" frameBorder="0" width="100%" scrolling="yes" height="100%"></iframe></td> </tr> <tr height=10> <td></td> </tr> </table> </form> </body> <