0

我正在尝试在我的 View 中访问 Dictionary 。但以下语法:

@{
    var indexList = Viewbag.IndexList as Dictionary<int,long>;
}

不起作用:The name 'Viewbag' does not exist in the current context

PS:尝试在 Viewbag 之前放置“@”,仍然不起作用。

有人可以帮忙吗?提前致谢

4

2 回答 2

5

不是 ViewBag 吗?

var indexList = ViewBag.IndexList as Dictionary<int,long>;
于 2012-04-13T07:53:37.293 回答
0

试试这个方法:

var indexList = this.ViewBag.IndexList as Dictionary<int,long>;
于 2016-06-03T00:51:17.853 回答