@ViewData["MyCustomCollection"]["MyParam1"] Q:我如何得到这个ViewData? ViewData它返回错误**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"
}
})MyCustomEditor
(...)
<span>@ViewData["MyCustomCollection"]["MyParam1"]<span>
<span>@ViewData["MyCustomCollection"]["MyParam2"]<span>
(...)重要的是:我需要将MyCustomCollection 设置为父级。我不能这么做:
@Html.EditorFor(model => model.MyCustomCollection, new
{
Param1 = "MyParam1"
Param2 = "MyParam2"
})发布于 2017-10-31 23:03:17
这是有可能的,做我想做的,遵循这个方法。
https://stackoverflow.com/questions/46985827
复制相似问题