-1

I'm trying to pass two objects to a view. My Action:

public ActionResult Edit(int ? id)
    {
        if (id == null)
        {
            RedirectToAction("AllBook");
        }
        Books model = new Books();


        model.GetUserAcount(); //A list for drop down list
        model.GetTheBook(id);  // Has a book information (int bookID, string BookTitl, int BookPrice)

        return View(model);

    }

I want to pass both of them to the view, any suggestions?

1 Answers1

0

Make a ViewModel which will contain data

public class ViewModel()
{
Books books{get;set;}
GetBook getbooks{get;set;}
}


While passing data to Model
ViewModel vm=new ViewModel();
vm.books="";
vm.getbooks="";

return View(vm);
faux
  • 91
  • 1
  • 10