如何在控制器上将jsonresult的数据显示到我的View?
请提供有关如何在视图上显示它的步骤。我是开发MVC4应用程序的新手。
以下是我的行动代码:
public ActionResult IndexChange(string ProposalID)
{
PurchaseOrderViewModel po;
int proposalId = 0;
proposalId = Convert.ToInt32(Session["ProposalID"]);
int ID = Convert.ToInt32(Session["InstitutionID"]);
List<Institution> lstInstitution = new List<Institution>();
lstInstitution = db.Institutions.Where(x => x.InstitutionID == ID).ToList();
List<NewProposal> lstPropospal = new List<NewProposal>();
lstPropospal = db.NewProposal.Where(x => x.ProposalID == proposalId).ToList();
ViewBag.Proposal = new SelectList(db.NewProposal.Where(x => x.Status.StatusID == 3), "ProposalID", "ProposalCode");
var model = new PurchaseOrderViewModel
{
Institution = lstInstitution,
Proposal = lstPropospal
};
return Json(model, JsonRequestBehavior.AllowGet);
}
答案 0 :(得分:0)
为什么要将其作为json发送...直接在您的视图return View(model)
在视图中导入您的模型,例如@model PurchaseOrderViewModel