Hi,
I want to pass a custom class to a View, along with an array derived from some of that class's values. I can pass the array without problems, but I've got no idea on how to pass the class as a whole - I'm new to OO programming, never mind MVC.
I've created a ViewModel which looks like this: (put together after reading the Nerddinner & Msuic Store tutorials)
namespace CourseViewMaps.ViewModels
{
public class CourseViewMapViewModel
{
public List<CourseStreamUnitDetail> CourseStreamUnitDetails { get; set; }
public CourseViewMapViewModel() { }
public CourseViewMapViewModel(List<CourseStreamUnitDetail> unitdetails
)
{
this.CourseStreamUnitDetails = unitdetails;
}
public Array CategoryNames { get; set; }
}
}
And am currently passing the array to the view as such:
var ViewData = new CourseViewMapViewModel()
{
CategoryNames = arrayOut.ToArray()
//arrayOut is derived from a CourseStreamUnitDetail property
};
return View(ViewData);
I know I'm missing something in the ViewData declaration, but can't figure out what. If it is simply to add a var for CourseViewMapViewmodel(), how do I do that??
Any help would be much appreciated!