the problem is whenever i try to save the data using the view. I always get null data. Please help. My codes for controller, models and view are as follows. Thanks.
public class OverallData
{
public List<UserInfo> userInfo = new List<UserInfo>();
public UserActivity userActivity = new UserActivity ();
}
public class UserInfo
{
public int UserID { get; set; }
public action UserName { get; set; }
public action UserPassword { get; set; }
}
public class UserActivity
{
public int ActivityID{ get; set; }
public string ActionPerformed { get; set; }
}
View
@model BusinessProcess.Models.OverallData
<h1>List of Usernames</h1>
@foreach (var item in Model.userInfo)
{
@Html.DisplayFor(modelItem => item.UserName)
}
<h1>Enter some action Performed</h1>
@using (Html.BeginForm("EditUserActivity", "ManageUser", FormMethod.Post, new { id = "EditUserActivity" }))
{
@Html.ValidationSummary()
@Html.DisplayNameFor(model => model.userActivity.ActionPerformed)
@Html.EditorFor(model => model.userActivity.ActionPerformed)
<button type="submit">Save</button>
}
Controller
[HttpPost]
public string EditUserActivity(UserActivity tempUserActivity)
{
string postedValue = tempUserActivity.ActionPerformed;
//When i debug this the "postedValue" is null
}
OverallData.userActivity
a property instead of a field?