我试图将两个对象传递给视图。 我的行动:
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);
}
我想将它们都传递给视图,有什么建议吗?
答案 0 :(得分:0)
制作一个包含数据的ViewModel
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);