同一级的node其Value不能相同下面的内容来自MSDN:http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.treenode.value(VS.80).aspxNodes at the same level must each have a unique value for the Value property; the TreeView control cannot distinguish between different nodes at the same level that have the same value. In this scenario, if the user clicks a node that has a duplicate value, the node that appears first in the TreeView control is selected.
在treeview这个树控件上,若给同一级别的不同节点设置相同的 Value 属性,则访问控件的 SelectedNode 属性时,将不能得到正确的被选中节点。这是。net2.0treeview控件本身的一个bug。 若同一节点,value值相同,则返回相同值中索引最小的节点
你的TreeView是不是设置了什么属性?
<asp:TreeView ID="TreeView1" runat="server"
onselectednodechanged="TreeView1_SelectedNodeChanged">
<Nodes>
<asp:TreeNode Text="111" Value="111">
<asp:TreeNode Text="aaa" Value="aaa"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="222" Value="222">
<asp:TreeNode Text="bbb" Value="bbb"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="333" Value="333">
<asp:TreeNode Text="ccc" Value="ccc"></asp:TreeNode>
</asp:TreeNode>
</Nodes>
</asp:TreeView>protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
string name = TreeView1.SelectedNode.Text;
}
如果value值一样就出现你说的那种情况了。
把你的Page_load代码和Aspx中Treeview的部分贴出来吧。
对这种税法完全不理解,要绑定什么????????????
同一级的node其Value不能相同下面的内容来自MSDN:http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.treenode.value(VS.80).aspxNodes at the same level must each have a unique value for the Value property; the TreeView control cannot distinguish between different nodes at the same level that have the same value. In this scenario, if the user clicks a node that has a duplicate value, the node that appears first in the TreeView control is selected.
若同一节点,value值相同,则返回相同值中索引最小的节点