读取 ViewData 子值

Read ViewData Sub Values

问:如何获取这个ViewData? @ViewData["MyCustomCollection"]["MyParam1"]它returns错误Cannot apply indexing with [] to an expression of type 'object'

视图(MyCustomCollecion 有 [UIHint("MyCustomEditor")]

@Html.EditorFor(model => model.MyCustomCollection, new
{
    MyCustomCollection = new
    {
        Param1 = "MyParam1"
        Param2 = "MyParam2"
    }
})

我的自定义编辑器

(...)
<span>@ViewData["MyCustomCollection"]["MyParam1"]<span>
<span>@ViewData["MyCustomCollection"]["MyParam2"]<span>
(...)

重要提示:我需要将 MyCustomCollection 设置为父项。我不能这样做:

@Html.EditorFor(model => model.MyCustomCollection, new
{
   Param1 = "MyParam1"
   Param2 = "MyParam2"
})

按照这种方法,可以做我想做的事。