public void ParentNode()    //创建父节点
    {
        string sql;
        if (p == "999999")
        {
            sql = "select id,LBMC from WJLBB where parent_id=0";
        }
        else
        {
            sql = "select id,LBMC from WJLBB where parent_id=0 and bmbh='" + bmbh + "'";
        }
        DataSet ds = newdbclient.DataSets(sql);
        if (ds.Tables[0].Rows.Count != 0)
        {
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                TreeNode tn = new TreeNode();
                tn.Text = ds.Tables[0].Rows[i]["LBMC"].ToString();
                tn.Value = ds.Tables[0].Rows[i]["id"].ToString();
                TreeView1.Nodes.Add(tn);
                ChildNode(tn, tn.Value);
                //this.treeView1.Nodes.Add("onclick", "CheckEvent()");
            }
        }

    }

    public void ChildNode(TreeNode node, string fdeptid)    //递归取出父节点下的子节点
    {
        string sql = "select id,LBMC from WJLBB where kf='开放' and parent_id='" + fdeptid + "'";
        DataSet ds = newdbclient.DataSets(sql);
        if (ds.Tables[0].Rows.Count != 0)
        {
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                TreeNode tn = new TreeNode();
                tn.Text = ds.Tables[0].Rows[i]["LBMC"].ToString();
                tn.Value = ds.Tables[0].Rows[i]["id"].ToString();
                node.ChildNodes.Add(tn);
                //UserNode(tn, tn.Value);     //在子节点下创建人员节点
                ChildNode(tn, tn.Value);
            }
        }
    }

相关文章:

  • 2022-12-23
  • 2022-02-22
  • 2021-12-13
  • 2021-07-24
  • 2022-12-23
  • 2021-11-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案