Wants to create

  • based structure  by using table based on parent child roots upto n levels .. facing an issu

    • TECH
      • Company Maintenance
      • Employees
      • Human Resources
    • XRP
      • Company Maintenance
      • Employees
      • Human Resources

    write  below code but facing an issue:

      using (DatabaseContext ctx = new DatabaseContext())
          {
            var Alllocations = ctx.GetAllLocations().Where(x => x.ClientId == clientno);
            int count = Alllocations.Count();
            foreach (var location in Alllocations)
            {
              int LevelCount = 0;
              string[] leveld;
              LevelCount = location.LevelID.Split('>').Length;
               leveld=  location.LevelID.Split('>');
              string max=string.Empty;
              int level = 0;
              
              for (int i = 0; i <=LevelCount; i++)
              {
                if (location.ParentID == null&& LevelCount==1)
                {
                  Option += "

      ";
                  }
                  max = leveld.Max();
                  level++;
                }
                int n = 0;
                while (n != level)
                {
                  if (max != string.Empty && n==level)
                  {
                    Option += "
    ";
                  break;
                }
                n++;
              }
              

              Option += "

  • "+ ""+location.Self_Description + "" + "
  • ";
                //Option += "