开发者

Passing data from controller to view

开发者 https://www.devze.com 2023-04-01 16:48 出处:网络
开发者_StackOverflow社区I have a silly question : In my controller I set : ViewBag.totalCount = 20

开发者_StackOverflow社区I have a silly question : In my controller I set :

ViewBag.totalCount = 20

In the view I want to call:

@Html.Pager(8, 1, @ViewBag.totalCount);

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!


Just need

@Html.Pager(8, 1, (int)ViewBag.totalCount)

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 should be ViewBag.totalCount, not @ViewBag.totalCount.

0

精彩评论

暂无评论...
验证码 换一张
取 消