我需要在從控制器通過視圖傳遞的部分視圖中使用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 –