Q: How can I get this ViewData? @ViewData["MyCustomCollection"]["MyParam1"]
it returns the errorCannot apply indexing with [] to an expression of type 'object'
View (MyCustomCollecion has [UIHint("MyCustomEditor")]
@Html.EditorFor(model => model.MyCustomCollection, new
{
MyCustomCollection = new
{
Param1 = "MyParam1"
Param2 = "MyParam2"
}
})
MyCustomEditor
(...)
<span>@ViewData["MyCustomCollection"]["MyParam1"]<span>
<span>@ViewData["MyCustomCollection"]["MyParam2"]<span>
(...)
Important: I need to set MyCustomCollection
as a parent. I cannot do this:
@Html.EditorFor(model => model.MyCustomCollection, new
{
Param1 = "MyParam1"
Param2 = "MyParam2"
})
It's possible to do what I was trying to, following this approach.