1) Let's say I have a MyDataInfo class:
public class MyDataInfo
{
public int MyDataInfoID { get; set; }
public string Name { get; set; }
}
In terms of the functionality that I use, I created another class ( MyData strong>), whose property elements are of type MyDataInfo.
2) Here MyData p>
public class MyData
{
public MyDataInfo Prop1 { get; set; }
public MyDataInfo Prop2 { get; set; }
}
3) And here is my method of action
public ActionResult MyAction()
{
MyData myObject = new MyData();
return View(myObject);
}
4) Finally, this is in my View template (which is strongly typed and inherits from MyData strong>)
<%= Html.Encode (Model.Prop1.Name) %>
<%= Html.Encode (Model.Prop2.Name) %>
Unfortunately, I got an error " The object is not installed in the object instance ."
Am I missing something or is there another way to get the same result?
source
share