Click here to Skip to main content
12,356,052 members (66,667 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
i have already gon all
MLM logic
but not work for me or not got properly
TRID                 CID                  MCID                 PRDID      
-------------------- -------------------- -------------------- ----------- 
1                    1                    0                    1           
2                    2                    1                    1           
3                    3                    1                    3          
4                    4                    2                    2           
5                    5                    3                    2           
6                    6                    6                    3           
7                    7                    3                    2           
8                    8                    2                    2           
9                    9                    1                    2           
10                   10                   4                    4           
11                   11                   10                   2           

MCID Master ID and CID means Child

MLM objMLM = new MLM();
  int q;
  protected void Page_Load(object sender, EventArgs e)
  {
      if (!IsPostBack)
      {
          DataSet MLMUser = objMLM.SelectNode("1");
          if (MLMUser.Tables[0].Rows.Count > 0)
          {
              ChildNode(MLMUser);
          }
      }
 

  }
  private void ChildNode(DataSet Parent)
  {
      TreeLogic(Parent);
 
      if (Parent.Tables[0].Rows.Count > 0)
      {
 

          if (Parent.Tables[0].Rows[0]["MCID"].ToString() == Parent.Tables[0].Rows[0]["CID"].ToString())
          {
              q = 1;
          }
          else
          {
              q = 0;
          }
          for (int i = q; i < (Parent.Tables[0].Rows.Count); i++)
          {
 
              string MID = Parent.Tables[0].Rows[i]["CID"].ToString();
              DataSet MLMUserChild = objMLM.SelectNode(MID);
              if (MLMUserChild.Tables[0].Rows.Count > 0)
              {
                  ChildNode(MLMUserChild);
              }
 
          }
 

 
      }
 

  }
    private void TreeLogic(DataSet Parent)
  {
      TreeNode childnode, headnode;
      headnode = new TreeNode();
      if (TreeView1.Nodes.Count == 0)
      {
 

 
          headnode.Text = Parent.Tables[0].Rows[0]["MCID"].ToString();
          TreeView1.Nodes.Add(headnode);
          if (Parent.Tables[0].Rows[0]["MCID"].ToString() == Parent.Tables[0].Rows[0]["CID"].ToString())
          {
              q = 1;
          }
          else
          {
              q = 0;
          }
          //Loop for binding Parent Values
          for (int i = q; i < Parent.Tables[0].Rows.Count; i++)
          {
              TreeNode firstchild = new TreeNode();
              firstchild.Text = Parent.Tables[0].Rows[i]["MCID"].ToString();
 

 
              //Loop for binding Child Values.
              for (int j = 0; j < Parent.Tables[0].Rows.Count; j++)
              {
                  childnode = new TreeNode();
                  childnode.Text = Parent.Tables[0].Rows[j]["CID"].ToString();
                  headnode.ChildNodes.Add(childnode);
 
                  //more over can expand the list.

              }
              break;
          }
      }
      else
      {
 

 
          foreach (TreeNode node in TreeView1.Nodes)
          {
 

 

              TreeNodeCollection child = node.ChildNodes;
 

              for (int i = 0; i < child.Count; i++)
              {
 
                  for (int j = 0; j < Parent.Tables[0].Rows.Count; j++)
                  {
                     ["CID"].ToString();
                      if (child[i].Text == Parent.Tables[0].Rows[j]["MCID"].ToString())
                      {
                          childnode = new TreeNode();
                          childnode.Text = Parent.Tables[0].Rows[j]["CID"].ToString();
                          child[i].ChildNodes.Add(childnode);
                      }
 

                  }
 

              }
 

 

 

 
          }
    }
  }

ALTER PROCEDURE [dbo].[SelectNode]
	@User varchar(max)
AS
BEGIN
select * from TBL_TRN_PRODUCT where MCID=@User order by MCID
END
I get this output
OutPut My


but i want in right way as MLM under its parent other child should go

or i want to check if Child exist then add in dat child other child

MCID 4 10 are parent of 10 and 11 not coming i pic
Posted 17-Jan-13 0:27am
Edited 17-Jan-13 2:39am
v3
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I will give you two advices:
1) Your code is generating tree in vertical format which is visually not very good. As a multi level marketing user's perspective, I want to see who is the member in my branch(horizontally) and so on.
2) You are iterating the whole set of result and adding the found member as a child node for treeview. This will make your program very slow.

Now the solution:
1) Use repeater control and play with some css to create a horizontal display starting from root member to child members.
2) Go through This[^] example. This will give you generation as last column. This last column is the key to create your horizontal tree.

Best of luck.
  Permalink  
Comments
Member-515487 17-Jan-13 13:24pm
   
after that how to bind with tree view????
Member-515487 17-Jan-13 13:39pm
   
and horizontal format ?? means how letter on i want to add img of that Customer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160621.1 | Last Updated 24 May 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100