Return in the view more than one data list

1

In my return view (), how can I return two or more lists? These lists are the results of a linq query.

    
asked by anonymous 18.09.2014 / 19:52

1 answer

0

You can put it in the ViewBag

ViewBag.Lista1 = new List<>();
ViewBag.Lista2 = new List<>();

return View();

Then the View you access the same way:

@ViewBag.Lista1

Now you can if you want, create a C # ViewModel class that is wrapper by joining the two lists in a new class

return View(new MyViewModel{ Lista1 = new List<>(), Lista2 = new List<>() });

There you will see:

@Model.Lista1

Exit?

    
18.09.2014 / 20:08