从控制器传递数据,查看 [英] Passing data from controller to view
本文介绍了从控制器传递数据,查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个愚蠢的问题:
在我的控制器我设置:
I have a silly question : In my controller I set :
ViewBag.totalCount = 20
在视图我想打电话:
@Html.Pager(8, 1, @ViewBag.totalCount);
但我认为,作为整个方法调用中VS.强调ViewBag无法识别它必须是简单的东西。我怎样才能使其好吗?谢谢!
but I think that ViewBag is not recognized as the whole method call is underlined in VS. It has to be something simple. How can I so it please ? Thanks!
推荐答案
刚需
@Html.Pager(8, 1, (int)ViewBag.totalCount)
假设它是一个 INT
(你需要投因为这将是动态
)。否 @
在ViewBag(因为你在code是的话),如果寻呼机返回非空,你可以省略后面的;
assuming it's an int
(you need to cast as it will be dynamic
). No @
in front of ViewBag (since you're already in code) and, if pager returns non-void, you can omit the trailing ;
这篇关于从控制器传递数据,查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文