我需要在从控制器通过视图传递的部分视图中使用ViewBag/TempData值。 controlller.cs如何在mvc的部分视图中传递和使用ViewBag/TempData值4
var category = (from s in context.M_ProductCategory
where s.ID == C_ID
select s.Title);
ViewBag.cat = category;
Index.cshtml
@{
Html.RenderPartial("PartialViewSpecification", new { ProductCategory = @ViewBag.cat });
}
我需要使用ViewBag.cat在PartialViewSpecification.Please值帮助
如果你想通过模型(即'IEnumerable')到部分视图,那么它需要是'Html.RenderPartial(“PartialViewSpecification”ViewBag.cat)',部分视图需要'@model IEnumerable –