我是 ASP 新手。我想知道我可以在控制器的变量传递视图中添加两个ViewData
变量吗?Razor
ASP.net MVC4
问问题
4082 次
1 回答
0
这是给你的示例代码
public ActionResult Detail(int id)
{
Model model=Repository.Find(id);
ViewData["key1"]="some data";
ViewData["key2"]="some other data";3
//or using ViewBag (dynamic type)
ViewBag.key1="some data";
ViewBag.key2="some other data";
return View(model);
}
在查看页面
@ViewData["key1"]
或者
@ViewBag.key1
于 2013-11-21T13:54:17.833 回答