private void InitTree2(TreeNodeCollection Nds,string parentId,int flag) { DataView dv=new DataView();
TreeNode tmpNd; dv.Table=dsTree.Tables[0]; dv.RowFilter="ParentId='" + parentId + "'" ;
foreach(DataRowView drv in dv) { tmpNd=new TreeNode();
tmpNd.ID = drv["ID"].ToString(); tmpNd.Text = "<INPUT type='checkbox' id='chkPlan' value='"+drv["ID"].ToString()+"' onclick='searchArea(this);'>"+drv["DName"].ToString();
tmpNd.NavigateUrl="DestLocalEdit.aspx?ID="+drv["ID"].ToString()+"&ParentID="+drv["ParentID"].ToString();
Nds.Add(tmpNd); InitTree2(tmpNd.Nodes,tmpNd.ID,flag); } }
如果你希望知道当前选中的是哪些节点,其实可以换个思路, 首先在页面上方一个<INPUT id="Text1" type="hidden" name="Text1" runat="server" value=",">
然后改写一下 searchArea : function searchArea(objTreeCheckBox) { var curID = objTreeCheckBox.value; var selected = document.getElementById("Text1").value; if(objTreeCheckBox.checked) selected += curID + ","; else selected = selected.replace(","+curID+",",",");
document.getElementById("Text1").value = selected; }
那么,无论是在javascript还是在后台C#代码中都可以随时获取目前选中的节点的value值 |