How to loop through two viewbag items on View pages in MVC 4.0

前端 未结 2 609
广开言路
广开言路 2020-12-31 05:27

I want to display a table in the MVC 4.0 View page that has following code:

Student
2条回答
  •  自闭症患者
    2020-12-31 05:55

    Look at this What's the difference between ViewData and ViewBag?

    It mean than you can loop through ViewBag items like this:

        @foreach (var viewBagItem in ViewContext.ViewData)
        {
            // your code
        }
    

提交回复
热议问题