How to display a list using ViewBag

前端 未结 9 2035
孤街浪徒
孤街浪徒 2020-12-05 03:07

Hi i need to show a list of data using viewbag.but i am not able to do it.
Please Help me..
I tried this thing:

 ICollection list = ne         


        
9条回答
  •  情歌与酒
    2020-12-05 03:37

         //controller  You can use this way
    
        public ActionResult Index()
        {
          List fundList = db.Funds.ToList();
         ViewBag.Funds = fundList;
            return View();
        }
    
    
    
    
    <--View ; You can use this way html-->
    
    @foreach (var item in (List)ViewBag.Funds)
    {
        

    @item.firtname

    }

提交回复
热议问题