日期:2014-05-19  浏览次数:20513 次

TreeView2.0的CheckBox取值问题(请大侠帮个忙,急呀)
在前台的JS里怎样才能根据选中的CheckBox获取它相应节点的值
在树生成的时候给节点赋的值在前台是没有的

请高手解答

------解决方案--------------------
Value得不到,只能得到Text
想得到Value得从后台想办法
------解决方案--------------------
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "TreeView.aspx.cs " Inherits= "TreeView " %>
<script type= "text/jscript ">
function UncheckParent (obj)
{
while(obj != null)
{
var tagName = obj.tagName.toLowerCase();

if(tagName == "div " && obj.id == "TreeView1 ")
{
return;
}

if( tagName== "table ")
{
var checkBox = obj.getElementsByTagName( "INPUT ");

if(checkBox.length > 0)
{
checkBox[0].checked = false;
}
obj = obj.parentElement.previousSibling;

}
else
{
obj = obj.parentElement;
}
}
}
function client_OnTreeNodeChecked()
{

var obj = window.event.srcElement;
var treeNodeFound = false;
var checkedState;
if (obj.tagName == "INPUT " && obj.type == "checkbox ")
{
var treeNode = obj;
checkedState = treeNode.checked;
if(!checkedState)
{
UncheckParent(obj);

}

do
{
obj = obj.parentElement;
}
while (obj.tagName != "TABLE ")

var parentTreeLevel = obj.rows[0].cells.length;
var parentTreeNode = obj.rows[0].cells[0];

var tables = obj.parentElement.getElementsByTagName( "TABLE ");
var numTables = tables.length
if (numTables > = 1)
{
for (i=0; i < numTables; i++)
{
if (tables[i] == obj)
{
treeNodeFound = true;
i++;
if (i == numTables)
{
return;
}
}
if (treeNodeFound == true)
{
var childTreeLevel = tables[i].rows[0].cells.length;
if (childTreeLevel > parentTreeLevel)
{
var cell = tables[i].rows[0].cells[childTreeLevel - 1];
var inputs = cell.getElementsByTagName( "INPUT ");
inputs[0].checked = checkedState;
}
else
{
return;
}
}
}
}
}
}
</script>
<form id= "Form1 " runat= "server ">
<asp:treeview id= "TreeView1 " runat= "server " ShowLines= "True " ShowCheckBoxes= "All " onclick= "client_OnTreeNodeChecked() " DataSourceID= "XmlDataSource1 "> </asp:treeview>
<asp:objectdatasource id= "ObjectDataSource1 " runat= "server "