1.ASP.NET MVC is different then ASP.NET where there are built in controls that you can see also in design mode.
2.In MVC you should use
razor code
and HTML elements (like
div
) in order to build your views.
3.From the
Controller
you should pass the
Model
to the
View
, and the
Model
that must contains the data that you want to display. Then in the view you should use
@foreach
(razor view block of code) to built dynamically each HTML groups of controls for each element.
4.In your case the Model should use razor code like in the next example:
public class StudentClassInfo
{
public string ClassName{get; set;}
public int ClassFloor{get;set;}
private List<StrudentInfo> _students= new List<StrudentInfo>();
public List<StrudentInfo> Students{ get {return _students;}}
}
public class StudentInfo
{
public string Name{get;set;}
}
5.In your view you should use your model data like in the next example:
@model List<StudentClassInfo>
<div>
@foreach (StudentClassInfo item in Model) {
<div>Class @item.ClassName @item.ClassFloor<br/>
<hr/>
@foreach(StudentInfo studentInfo in item.Students)
{
@studentInfo.Name
<br/>
}
<br/>
</div>
}
</div>