/// <summary> /// TreeView展开事件创建子节点,折叠事件进入展开事件将:EnableClientScript设置为false /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void TreeViewSilkItems_TreeNodeExpanded(object sender, TreeNodeEventArgs e) { if (e.Node.ChildNodes.Count == 0 && e.Node.Expanded.Value == true) { CreateChildNodes(e.Node); e.Node.Expand(); } if (e.Node.ChildNodes.Count > 0 && e.Node.Expanded.Value == false) { e.Node.Collapse(); } } protected void TreeViewSilkItems_TreeNodeCollapsed(object sender, TreeNodeEventArgs e) { if (e.Node.Expanded.Value == false) { e.Node.Collapse(); } else { e.Node.Expand(); } } /// <summary> /// 创建制丝项目节点 /// </summary> private void CreateChildNodes(TreeNode treeNode) { DataRow[] drs = dtSource.Select("FATHERID='" + treeNode.Value + "'"); if (drs.Length > 0) { for (int i = 0; i < drs.Length; i++) { TreeViewSilkItems.EnableClientScript = false; TreeNode tnValue = new TreeNode(drs[i]["MODELNAME"].ToString(), drs[i]["MODELID"].ToString()); tnValue.PopulateOnDemand = drs[i]["DEPTH"].ToString() != "3"; if (drs[i]["DEPTH"].ToString() == "3") { tnValue.ShowCheckBox = true; } treeNode.ChildNodes.Add(tnValue); } }