在vs2010中,怎么实现选择treeview的一个节点时,不让其他节点已经展开的节点自动收缩起来

解决方案 »

  1.   

    treeview里面有属性找找看呗!
      

  2.   


    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>无标题页</title>
        <script src="jquery-1.4.4.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function() {
                var treeId = '<%=this.TreeView1.ClientID %>';
                $("#" + treeId + " a").each(function() {
                    $(this).removeAttr("href");
                });
            });
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:TreeView ID="TreeView1" runat="server" DataSourceID="XmlDataSource1">
            </asp:TreeView>
            <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/XMLFile.xml"></asp:XmlDataSource>
        </div>
        </form>
        
        <%--下面是XMLFile.xml数据
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <bookstore>
      <book id="No1">
      <title>An Introduction to XML</title>
      <author>Chunbin</author>
      <year>2010</year>
      <price>98.0</price>
      
    </book>
      <book id="No2">
      <title>The Performance of DataBase</title>
      <author>John</author>
      <year>1996</year>
      <price>56.0</price>
    </book>
    </bookstore>--%>
    </body>
    </html>
      

  3.   

    可能有点不一样,以前只用过05的,只知道10的.net Framework是4.0的了
      

  4.   

    this.treeView1.SelectedNode.Expand(); // 展开子节点或者 遍历没有被选中的 设置节点收缩.