Using the view specified below I am able to get all my properties in just fine, and the Team
property contains the right number of items, but all of those items' properties are just null
...
View
@using (Html.BeginForm("BuildTeam", "Team", FormMethod.Post, new { crmtItem = Model, team = Model.Team }))
{
@Html.HiddenFor(m => m.Id);
@Html.HiddenFor(m => m.ProjectTitle);
@Html.HiddenFor(m => m.OpportunityStatus);
@Html.HiddenFor(m => m.ProjectManager);
@Html.HiddenFor(m => m.ProjectNumber);
@Html.HiddenFor(m => m.Sector);
@Html.HiddenFor(m => m.Service);
@Html.HiddenFor(m => m.Stage);
for (int i = 0; i < Model.Team.Count(); i++)
{
@Html.HiddenFor(m => m.Team[i].DisplayName)
@Html.HiddenFor(m => m.Team[i].UserName)
}
<a class="btn btn-default btn-sm" onclick="location.href='@Url.Action("Index", new { filter= Model.Stage })'"><span class="glyphicon glyphicon-circle-arrow-left"></span></a>
<a class="btn btn-default btn-sm" href="@Model.WorkspaceUrl"><span class="glyphicon glyphicon-globe"> Workspace</span></a>
<button type="submit" class="btn btn-default btn-sm pull-right">
<span class="glyphicon glyphicon-user" /> Team
</button>
}
ViewModel
public class CRMTItemViewModel
{
public int Id { get; set; }
public string ProjectTitle { get; set; }
public string ProjectManager { get; set; }
public string BidNoBid { get; set; }
public string OpportunityStatus { get; set; }
public string Stage { get; set; }
public string Sector { get; set; }
public string Service { get; set; }
public int? CRMTNumber { get; set; }
public int? ProjectNumber { get; set; }
public string WorkspaceUrl { get; set; }
public List<SharePointUser> Team { get; set; }
}
SharePointUser
public class SharePointUser
{
public string FirstName { get; internal set; }
public string LastName { get; internal set; }
public string UserName { get; internal set; }
public string DisplayName { get; internal set; }
public string ImagePath { get; internal set; }
public byte[] ImageBytes { get; internal set; }
public Guid GUID { get; internal set; }
}
Controller
[HttpPost]
public ActionResult BuildTeam(CRMTItemViewModel crmtItem, List<SharePointUser> team)
{
return View(crmtItem);
}
I originally only had the crmtItem
paramater in the Controller, but it still failed so I tried splitting it out but without any success.
Really aprpeciate any guidance on this.