WHy does my view Post back an empty List using the MVC code below:
//ProductViewModel ... public strProductName {get;set;} public List<ProductsViewModel> lstProducts { get; set; } ... //Controller public ActionResult AddProductQuestions() { ProductViewModel productviewmodel = new ProductViewModel(); productviewmodel.lstQuestions = new List<QuestionsViewModel>(); var query = from q in db.Questions select new QuestionsViewModel() { isSelected = new bool(), intId = q.Id, intIssueId= q.IssueId, strQuestion = q.Question, strResponse = q.Reponse }; productviewmodel.lstQuestions = query.ToList(); return View(productviewmodel); } //View @model MyApp.Models.ProductViewModel @using (Html.BeginForm("AddProduct","ManageProducts")) { ... //This Works and Gets the right Information from the Model when Posted <div class="form-group"> @Html.LabelFor(model => model.strProductName, htmlAttributes: new { @class = "control-label col-md-2" })<div class="col-md-10"> @Html.EditorFor(model => model.strProductName, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.strProductName, "", new { @class = "text-danger" })</div></div> ... //This Doesn't Post back it always comes back with Null @foreach (var item in Model.lstQuestions) { //var questionsCount = Model.lstQuestions.Count(); <tr><td>@Html.EditorFor(modelItem =>item.isSelected)</td><td> @item.intId</td><td> @item.intIssueId </td><td> @item.strQuestion </td><td> @Html.ActionLink("Edit", "Edit", new { id = item.intId }) | @Html.ActionLink("Details", "Details", new { id = item.intId }) | @Html.ActionLink("Delete", "Delete", new { id = item.intId })</td></tr> } ..
Thanks!