Marius Vasile

Marius Vasile

  • 594
  • 1.9k
  • 145.7k

ASP.NET Core Razor - cascade dropdown from 4 tables

Nov 18 2020 4:10 AM
The problem is I have 4 tables, Table 1, Table 2, Table 3 and Table 4. Table 1 has one-to-many relations with Table-2, Table 2 one-to-many to Table 3 and so on. all are similar on content, tables content below
 
  1. public class HazardsClass  
  2.     {  
  3.         [Key]  
  4.         public int IdHC { getset; }  
  5.         public string HazClass { getset; }  
  6.         public ICollection<HazardsDetail> HazardsDetails { getset; }  
  7.     }  
  8.   
  9.     public class HazardsDetail  
  10.     {  
  11.         [Key]  
  12.         public int IdH { getset; }  
  13.         public string HazDetail { getset; }  
  14.         public int IdHC { getset; }  
  15.         [ForeignKey("IdHC")]  
  16.         public HazardsClass HazardsClass { getset; }  
  17.   
  18.         public ICollection<HazardsPMClass> HazardsPMClasses { getset; }  
  19.     }  
  20.   
  21.     public class HazardsPMClass  
  22.     {  
  23.         [Key]  
  24.         public int IdPMC { getset; }  
  25.         public string HazPMClass { getset; }  
  26.         public int IdH { getset; }  
  27.         [ForeignKey("IdH")]  
  28.         public HazardsDetail HazardsDetail { getset; }  
  29.         public ICollection<HazardsPMDetail> HazardsPMDetails { getset; }  
  30.     }  
  31.   
  32.     public class HazardsPMDetail  
  33.     {  
  34.         [Key]  
  35.         public int IdPM { getset; }  
  36.         public string HazPMDetail { getset; }  
  37.         public int IdPMC { getset; }  
  38.         [ForeignKey("IdPMC")]  
  39.         public HazardsPMClass HazardsPMClass { getset; }  
  40.     }  
My problem is to view the information in dropdown lists, ex. First I choose a HazClass then from the list I choose a HazDetails and so on.  
 
 How do I do that?

Answers (6)