I am builing an ASP.Net mvc3 website which comprises of a series of forms all built on top of different models. Once the user fills up each form a "Confirm" page is shown which will show the fields of the form filled along with data in grid format to the user. I am facing difficulty in showing the Confirm view as the model keeps on changing for each form. Following is my Controller method for Confirm:
<pre lang="c#">public ActionResult Confirm(string ReqType)
{
var result = new List<dynamic>();
if (ReqType == "AcctDesc")
{
DbContext.AcctDescDbContext objAcctDescDbContext = new DbContext.AcctDescDbContext();
Models.AccountDesc objAcctDesc = objAcctDescDbContext.GetLatestRecord();
ViewData["AcctDesc"] = objAcctDesc;
ViewBag.ObjectModel = objAcctDesc;
var obj = (IDictionary<string, object>)new ExpandoObject();
obj.Add("Req_Name",objAcctDesc.Req_Name);
obj.Add("Req_Date",objAcctDesc.Req_Date);
obj.Add("ApprovalGroup",objAcctDesc.ApprovalGroup);
obj.Add("Account",objAcctDesc.AC_proposed);
obj.Add("Reason",objAcctDesc.AC_definition);
obj.Add("Language",objAcctDesc.AC_language);
obj.Add("CurrentShortText", objAcctDesc.AC_Currentshorttext);
obj.Add("CurrentLongText", objAcctDesc.AC_CurrentLongtext);
obj.Add("NewShortText", objAcctDesc.AC_Newshorttext);
obj.Add("NewLongText", objAcctDesc.AC_Newlongtext);
result.Add(obj);
}
ViewBag.result = result;
return View();
}
Following is the Confirm view:
@{
ViewBag.Title = "Confirm";
Layout = "~/Views/Shared/_LayoutMasterDataForms.cshtml";
}
<div>
@{
var grid = new WebGrid(ViewBag.result);
}
@using (Html.BeginForm())
{
<div id="grid">
@grid.GetHtml()
</div>
}
</div>
The problem is the gird is not getting rendered in the Confirm page-blank Html is coming up, what is the issue here? Please help.