i need to use ViewBag as list inside another ViewBag and i am not understanding how should i do that.
here is my code:
List<string> srclist = new List<string>();
foreach(var item in candidateportfolio)
{
if(item.PortfolioID!=0 && item.ChandidateID!=0)
{
string filepath = Server.MapPath("~/ePortfolio/PortFolioContent/" + HobbyDetailID + "/Assignments/Exhb_" + item.PortfolioID + "_" + item.ChandidateID + ".jpg");
if (System.IO.File.Exists(filepath))
{
srclist.Add(filepath);
}
}
}
ViewBag.Thumbnail = srclist;
选项ableportfolio 是类候选组合的对象 。
然后在 View 中我像这样使用 :
@foreach (var item in ViewBag.Thumbnail as List<string>)
{
<img src="@item" title="Learner:@ViewBag.FirstName" width="150px" height="150px" border="5" style="align:right;margin:10px"/>
}
现在的问题是,我还想要获取 ViewBag. firstName 作为列表。 我无法在此运行其它列表。 请告诉我该怎么做 。