又一treeView的问题,如何判断有多少子节点/或是否能判断父节点下,是否还有子节点!谢谢急

解决方案 »

  1.   

    参考
    http://blog.csdn.net/hgknight/archive/2004/06/13/13677.aspx//cs
    private void Page_Load(object sender, System.EventArgs e)
    {   
        TreeView1.Attributes.Add("onclick","tree_onclick(this)");
    }//js
    function tree_onclick(tree)
    {
     var node=tree.getTreeNode(tree.clickedNodeIndex);
     var ChildNode=new Array();
     ChildNode=node.getChildren(); 
     var len=parseInt(ChildNode.length)
    }
      

  2.   

    f exists (select * from dbo.sysobjects where id = object_id(N'[tb]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    drop table [tb]
    GO--示例数据
    create table [tb]([id] int identity(1,1),[pid] int,name varchar(20))
    insert [tb] select 0,'中国'
    union  all  select 0,'美国'
    union  all  select 0,'加拿大'
    union  all  select 1,'北京'
    union  all  select 1,'上海'
    union  all  select 1,'江苏'
    union  all  select 6,'苏州'
    union  all  select 7,'常熟'
    union  all  select 6,'南京'
    union  all  select 6,'无锡'
    union  all  select 2,'纽约'
    union  all  select 2,'旧金山'--1.得到指定id的子id列表
    create function f_getchildid(@id int)
    returns @re table(id int)
    as
    begin
     insert into @re select id from tb where pid=@id
     while @@rowcount>0
      insert into @re select a.id 
       from tb a inner join @re b on a.pid=b.id
       where a.id not in(select id from @re)
     return
    end
      

  3.   

    http://vcstudy.blogms.com/blog/CommList.aspx?TempleCode=1000000032&BlogLogCode=1001159019