public ActionResult DispListHelper() { //Create a dummy List of objects for testing purposes List<ComplexUserDTO> list = new List<ComplexUserDTO>(); ComplexUserDTO obj = new ComplexUserDTO(); obj.UserName = "******"; obj.Company = "Testing"; obj.Country = "Pakistan"; list.Add(obj); obj = new ComplexUserDTO(); obj.UserName = "******"; obj.Company = "Testing 1"; obj.Country = "Pakistan 1"; list.Add(obj); obj = new ComplexUserDTO(); obj.UserName = "******"; obj.Company = "Testing 2"; obj.Country = "Pakistan 2"; list.Add(obj); //here we are passing our model object to view, //At top of view, 'model' should be used to declare type of our object //In view, 'Model' property will be used to access this object //We can also call this object as 'ViewModel' return View(list); }
public ActionResult DispSimple() { //Create a dummy object for testing purposes ComplexUserDTO obj = new ComplexUserDTO(); obj.UserName = "******"; obj.Company = "Testing"; obj.Country = "Pakistan"; //here we are passing our model object to view, //At top of view, 'model' should be used to declare type of our object //In view, 'Model' property will be used to access this object //We can also call this object as 'ViewModel' return View(obj); }