I want to display a table in the MVC 4.0 View page that has following code:
<table >
  <thead>           
    <tr>
      <th>Student Name</th>
      <th>Gaurdian</th>
      <th>Associate Teacher</th>
    </tr>
  </thead>
  @foreach(var stud in ViewBag.students)
  { 
     <tr>
         <td>@stud.Name</td>
     </tr>
   }
</table>
This works fine.But , the Guardian information and the associate teacher information is put in different ViewBag objects like ViewBag.guardians and Viewbag.assoc. How should i loop through them to display them in required table cells??
Loops within the loop like
   @foreach(var student in ViewBag.students)
  { 
    foreach(var gaurdian in ViewBag.guardians)
    {     
      <tr>
        <td>@student.Name</td>}
        <td>@guardian.Name</td>
      </tr>
    }
  }
sounds to be ridiculous. Please provide me proper solution. The student class contains guardian field but it has its own another class as follows:
      public class Student
      {
         public string Name {get;set;}
         public string RollNo {get;set;}
         public virtual Guardian Guardian {get;set;}
         public IList<Guardian> GuardianName {get;set;}
      }
       public class Guardian
      {
         public string Name{get;set;}
         public string MobNumber{get;set;}
       }  
      public class Associate
       {
          public string AID{get;set;}
          public virtual Student Student{get;set;}
          public string RollNo {get;set;}
       }            
 
     
     
    