Click here to Skip to main content
15,918,808 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
public ActionResult Create()
        {
            List<Gallery> gallist = db.galleries.ToList();
            return View(gallist);
        }


In this Im sending gallery class object(i.e; gallist)from controller to view.
If i want to send two class objects? from controller to view.i.e;

XML
public ActionResult Create()
        {
            List&lt;Gallery&gt; gallist = db.galleries.ToList();
            List&lt;Docs&gt; doclist= db.documents.ToList();
            return View(gallist,doclist);
        }


Actually its impossible.How i can achieve it?(with out using viewbag,viewdata,tempdata)
Posted

1 solution

Quote:
If i want to send two class objects? from controller to view

You can use ViewModel to pass multiple Models to View.

And , Of-course you can try other ways too.

Refer the below link which will be helpful .

Using Multiple Models in a View in ASP.NET MVC 4[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900