Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have multiple lists like
XML
List<Book> ventureCats = new List<Book>();
        List<Bookgallery= new List<Bookgallery>.GetAll();
        List<BookDocument> venDocs = BookDocument.GetAll();
        List<ImageGallery> ImgGallery = new List<ImageGallery>();
Posted

As to give example
Put them in a another class which will contain the list of object this
class BookList
{
public List<book> book{get;set;}
public List<bookgallery> bookgallery{get;set;}
public List<bookdocument> bookdocument{get;set;}
public List<imagegallery> ImgGallery{get;set;}
}</imagegallery></bookdocument></bookgallery></book>

in you controller
BookList bl=new BookList();
bl.Book=getBook();//get your collection
bl.bookgallery=new List<bookgallery>.Getall();
bl.bookdocument=BookDocument.GetAll();
bl.ImgGallery=new List<imagegallery>();
</imagegallery></bookgallery>

//Return this class your you will get this in your model
return view(bl);
 
Share this answer
 
Comments
laxmi smiley 6-Jun-14 6:04am    
i created a strongly typed view of type BookList.
but i am getting compilation error at
@foreach (var item in Model) {
}
Prasad Avunoori 9-Jun-14 2:12am    
What is the error?
C#
public ActionResult ViewBagDemo()
{

List<book> ventureCats = new List<book>();
        List<bookgallery>  bookgallery= new List<bookgallery>.GetAll();
        List<bookdocument> venDocs = BookDocument.GetAll();
        List<imagegallery> ImgGallery = new List<imagegallery>();
    ViewBag.ventureCats = ventureCats;
    ViewBag.Bookgallery = bookgallery;
    ViewBag.venDocs = venDocs;
     ViewBag.ImgGallery = ImgGallery;
    return View();
}
 
Share this answer
 
v2

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