I am creating project for mlm company they want to tree of the members thes have anthe sub tree of that members
so anybody have idea so please help me as soon as possible
thanks in advance
work will be appriaciated

Dani AI

Generated

A practical, maintainable approach for an MLM/family tree is to separate the data model from the UI. and were correct that ASP.NET TreeView is a convenient display control, and 's org‑chart idea fits the same model. The usual backend pattern is an adjacency list (Members table with a nullable ParentId) — prefer NULL for root nodes rather than magic values like -1 so foreign keys and indexes behave predictably.

Example schema and a simple server-side query + bind pattern:

CREATE TABLE Members (
  MemberId INT IDENTITY(1,1) PRIMARY KEY,
  ParentId INT NULL,
  FullName NVARCHAR(200),
  JoinDate DATETIME
);
CREATE INDEX IX_Members_ParentId ON Members(ParentId);

Recursive SQL (SQL Server) to fetch a subtree:

WITH MemberTree AS (
  SELECT MemberId, ParentId, FullName, 0 AS Level
  FROM Members WHERE MemberId = @rootId
  UNION ALL
  SELECT m.MemberId, m.ParentId, m.FullName, mt.Level + 1
  FROM Members m
  JOIN MemberTree mt ON m.ParentId = mt.MemberId
)
SELECT * FROM MemberTree ORDER BY Level;

A minimal C# recursive binder for an ASP.NET TreeView:

void BuildNodes(TreeNodeCollection nodes, List<Member> all, int? parentId) {
  foreach(var m in all.Where(x => x.ParentId == parentId)) {
    var n = new TreeNode(m.FullName) { Value = m.MemberId.ToString() };
    nodes.Add(n);
    BuildNodes(n.ChildNodes, all, m.MemberId);
  }
}

Notes and tips: add an index on ParentId; use lazy loading / PopulateOnDemand for large trees; consider materialized-path or nested-set models for very large, read‑heavy trees (they speed subtree queries but complicate inserts/updates). For true genealogies (multiple parents, spouses), model relationships in a separate table instead of a single ParentId. Include cycle detection and depth limits so recursive rendering cannot loop indefinitely.

Recommended Answers

All 5 Replies

can anybody tell me why -1
here for help

you mean organizational structure of your company? from president down to rank and file?

use navigation -> treeview

-1 means parent node..

Making a family tree is an easy task in ASP.net you just need to use the navigation control on left side of the screen and there we have the option for tree view.using it we can make family tree.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.