本帖最后由 pan123799403 于 2010-07-24 17:39:34 编辑

解决方案 »

  1.   

    建议去www.51aspx.com网站上DOWN个例子
      

  2.   

    楼主会学习吗?会百度,会GOOGLE吗?不要告诉我,你找不到例子啊。
      

  3.   

    你仔细观察,id 值,下级的id 包含了上级的id。还不会添加进树形控件?
      

  4.   

    递归绑定数据,substring(1,3)或charindex
    http://topic.csdn.net/u/20100628/21/8be22000-dca4-478c-b96d-f19574c0c228.html
      

  5.   


     private void bind()
        {
            string temp = "<ul class='simpleTree'>";
            DataSet ds = db.getDs();
            DataRow[] dr = ds.Tables[0].Select("department_code='001'");
            Response.Write("为了测试,当前总行数为:" + "<a style='color=red'>"+ds.Tables[0].Rows.Count+"</a><div style='height=10px;background-color:white'></div>");
            
            foreach (DataRow r in dr)
            {
                string name = r["department_name"].ToString();
                string code = r["department_code"].ToString();
                temp += "<li class='root' id='li1' name='" + name + "'><span id='s1' oncontextmenu = showMenu('" + i + "')  name='" + name + "' class='" + code + "'>" + name + "</span>";
                if (AddChildNode(ds, code) != "" || AddChildNode(ds, code)!=null)
                 {
                     temp += "<ul>" + AddChildNode(ds, code);
                     ds.Tables[0].Rows.Remove(r);             }
                
            }         
            temp += "</ul>";
          
            mytree.InnerHtml = temp;
          
        }    public string AddChildNode(DataSet ds, string department_code)
        {
            i++;        string a = "";
            DataRow[] dr = ds.Tables[0].Select("parent_department='" + department_code + "'");
            int count = dr.Length;        if (dr != null)
            {            foreach (DataRow r in dr)
                {
                    string code = r["department_code"].ToString();                string name = r["department_name"].ToString();
                    a += "<li id='li" + i + "' class='" + code + "' name='" + name + "'><span id='s" + i + "' oncontextmenu = showMenu('" + i + "') name='" + name + "' class='" + code + "'>" + name + "</span></li>";
                    if (AddChildNode(ds, code) == "" || AddChildNode(ds, code) == null)
                    {                }
                    else
                    {
                        a += "<ul>" + AddChildNode(ds, code) + "</ul>";
                         
                    }
                                 }        }
             
            return a;
        }
        
        
      

  6.   

    我现在写一个demo,在 http://topic.csdn.net/u/20100724/18/b5927dbb-bb6b-40e3-858c-4063d2479efc.html