【发布时间】:2014-02-04 23:50:30
【问题描述】:
如何将控制器上的 jsonresult 中的数据显示到我的视图中?
请提供如何在视图上显示它的步骤。我是开发 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);
}
【问题讨论】: