Is there a way to obtain a model object from the view into the controller without using strongly typed HTML helpers. The View uses the Account
entity But need to post the form and retrieve the account entity of the variable running in a foreach
loop used to generate the table/grid of values. The information from the dropdown is used for a different entity hence why its not strongly typed.
public class HomeController : Controller
{
// GET: Home
ModelContext model = new ModelContext();
[HttpGet]
public ActionResult Index()
{
return View(model.accounts.ToList());
}
[HttpPost]
public ActionResult Index(Account account,List<string> status,string name)
{
// return student object
return View();
}
}
The rest of the code in the View runs on a foreach
loop to generate an html table
enclosed in a @HTML.BeginForm
<td>
@Html.DropDownList("status",
new SelectList(Enum.GetValues(typeof(ProjectName.Models.Code))),
"...",
new { @class = "form-control" })
</td>
<td>
@Html.TextArea("comment");
</td>