title: how to display MLM data in treeview in asp.net
body: <p><a href="https://i.stack.imgur.com/H2LcO.jpg" rel="nofollow noreferrer">MLM data sample</a></p>
  
  <p>i have multilevel marketing software data in which a person may join many other person and again joind person will do the same.</p>
  
  <p>i have tried these code</p>
  
  <pre><code>     protected void load_data()
           {
  
          strQuery = "select * from redjoining where id=995";
          cmd = new SqlCommand(strQuery);
          dt = dbcon.GetData(cmd);
  
          string cat_code = dt.Rows[0]["id"].ToString();
          string cat_name = dt.Rows[0]["userName"].ToString();
  
          TreeNode parent = new TreeNode();
          parent.Value = cat_code;
          parent.Text = cat_name;
          TreeView1.Nodes.Add(parent);
          add_childs(parent, cat_code);
  
      }
  </code></pre>
  
  <p>now to add child node i use this code but it add only top single record only.</p>
  
  <pre><code>  protected void add_childs(TreeNode tn, string category_code) 
    {
  
          strQuery = "select * from redjoining where sponserid=@category_code";
          cmd = new SqlCommand(strQuery);
          cmd.Parameters.AddWithValue("@category_code", category_code);
          dt = dbcon.GetData(cmd);
  
          for (int i = 0; i &lt; dt.Rows.Count; i++)
          {
              string cat_code = dt.Rows[0]["id"].ToString();
              string cat_name = dt.Rows[0]["userName"].ToString();
  
              TreeNode child = new TreeNode();
              child.Value = cat_code;
              child.Text = cat_name;
              tn.ChildNodes.Add(child);
  
              add_childs(child, cat_code); //calling the same function
          }
      }
  </code></pre>