asp.net 获取TreeView中第一个选中的节点
(编辑:jimmy 日期: 2024/11/6 浏览:3 次 )
复制代码 代码如下:
private TreeNode GetSelectedGroup(TreeView tv)
{
foreach (TreeNode item in tv.Nodes)
{
if (item.Checked)
{
return item;
}
else
{
return GetSelectedChildGroup(item);
}
}
return null;
}
TreeNode result = null;
private TreeNode GetSelectedChildGroup(TreeNode treeNode)
{
foreach (TreeNode item in treeNode.ChildNodes)
{
if (item.Checked)
{
return item;
}
else
{
result = GetSelectedChildGroup(item);
}
}
return result;
}
private TreeNode GetSelectedGroup(TreeView tv)
{
foreach (TreeNode item in tv.Nodes)
{
if (item.Checked)
{
return item;
}
else
{
return GetSelectedChildGroup(item);
}
}
return null;
}
TreeNode result = null;
private TreeNode GetSelectedChildGroup(TreeNode treeNode)
{
foreach (TreeNode item in treeNode.ChildNodes)
{
if (item.Checked)
{
return item;
}
else
{
result = GetSelectedChildGroup(item);
}
}
return result;
}
下一篇:asp.net GridView控件中实现全选的解决方案