0
我有如下的主视图:局部视图之间Asp.Net的mvc传递参数
<div class="wellContainer" id="stockCardGroupContainer">
@Html.Action("_StockGroupMenu", new { stockGroupId = 1})
</div>
<div id="stockCardContainer" class="wellContainer">
@Html.Action("_Index", "WrhStockCard", new { stockGroupId = ViewBag.wrhRelatedStockGroupId })
</div>
这里是返回部分视图的方法。
public PartialViewResult _StockGroupMenu(int? id)
{
var wrhStockGroup = db.WrhStockGroup.Include(w => w.RelatedWrhStockGroup).Where(p => p.RelatedWrhStockGroupId == id);
ViewBag.wrhRelatedStockGroupId = id;
ViewBag.stockGroupName = db.WrhStockGroup.Find(id).Name;
return PartialView(wrhStockGroup.ToList());
}
public PartialViewResult _Index(int? stockGroupId)
{
var relatedStockCards = stockCardService.GetStockCardsByGroupId(stockGroupId);
ViewBag.stockGroupId = stockGroupId;
ViewBag.stockGroupName = db.WrhStockGroup.Find(stockGroupId).Name;
return PartialView(relatedStockCards);
}
的情况是,当用户单击一个组,我需要显示股票卡“stockCardContainer”,也显示出,在stockCardGroupContainer相关childGroupd。但我在_StockGroupMenu方法中设置ViewBag.wrhRelatedStockGroupId,但不能将它传递给第二个@ Html.Action,因为它是不同的局部视图。