Edit: Removed Partial View to make things simpler. Now I just need to find out why The View isn't Posting the Values
ViewModelProspectUsers
public class ViewModelProspectUsers { public int Id { get; set; } public string User { get; set; } public IEnumerable<ViewModelProspectSelect> Prospects { get; set; } }
ViewModelProspectSelect
public class ViewModelProspectSelect { public int ProspectID { get; set; } public string Name { get; set; } public bool IsSelected { get; set; } }
View
@model OG.ModelView.ViewModelProspectUsers @using (Html.BeginForm()) { @Html.HiddenFor(model => model.Id) <h5>Please Select Prospects you wish to assign to this User.</h5>
-----HERE is where the partial used to be, these values aren't being posted to the [Post]
Method------
-----------------------------------------However they are populating just fine----------------------------------------
@foreach (var item in Model.Prospects)
{
@Html.HiddenFor(x => item.ProspectID)
@Html.DisplayFor(x => item.Name)
@Html.EditorFor(x => item.IsSelected)
}
@*@Html.Partial("_ShowProspectCheckedForUser", Model.Prospects)*@
@*@Html.Partial("_ShowProspectCheckedForuser", new OG.ModelView.ViewModelProspectSelect())*@
<input type="submit" value="Save changes" />
@Html.ActionLink("Cancel", "Index")
}
Post
[HttpPost] public ActionResult UsersInProspect(ViewModelProspectUsers viewModel)
If i were to look at viewModel.Prospects(m=>m.isSelected)
//<- this value is Null shouldn't be
My viewmodel Variableis showing Data but not for the Ienumerable.