Hi, I believe manchanx explained nicely what problem you are facing and how to solve it, but nevertheless I will just add another suggestion that you can use.
You can create a main table (like a sort of a container), that would have a single row and in each of that row's cells you would have a nested table, so something like this:
@model IEnumerable<ClassRoom>
@{
ViewBag.Title = "My ClassRoom";
}
<h2>My My ClassRoom</h2>
<table>
<tr>
@foreach (var item in Model)
{
<td>
<table class="table">
<tr>
<th>
@Html.DisplayFor(modelItem => item.TeacherName)
</th>
</tr>
@foreach (var name in item.StudentNames)
{
<tr>
<td>
@Html.DisplayFor(modelItem => name.FirstName)
</td>
</tr>
}
</table>
</td>
}
</tr>
</table>