怎样得到Treeview的checkbox的值
var checkCount = 0;
/***********************得到选中的CheckBox的行绑定的值,如Eval("Guid")******************************/
function GetCheckedBoxValues() {
var checkedBoxValues = "0";
var inputs = document.getElementById("table1").getElementsByTagName("input");
for (var j = 0; j < inputs.length; j++) {
if (inputs[j].type == "checkbox" && inputs[j].id != "checkboxAll" && inputs[j].id != "CheckBoxListGroup_0") {
if (inputs[j].checked == true) {
checkedBoxValues += ("," + "'" + inputs[j].value + "'");
checkCount++;
}
}
}
alert(checkedBoxValues);
return checkedBoxValues;
}
<table cellpadding="10" cellspacing="0" border="0" width="100%" id="table1">
<tr>
<td>
<asp:TreeView ID="TreeViewData" runat="server" ShowCheckBoxes="All" ShowLines="True">
<RootNodeStyle Font-Bold="False" Font-Size="14px" />
</asp:TreeView>
</td>
</tr>
</table>
<input type="button" value="测试" onclick="GetCheckedBoxValues()" />
每次点击 测试按钮 都弹出 0,'on'
------解决方案--------------------
foreach(TreeNode node in TreeView1.Nodes)
{
if(node.Checked==true)
{
}
}
遍历这个TeeeView,看节点是否被选中
------解决方案--------------------