问题是每当我尝试使用视图保存数据时。我总是得到空数据。请帮忙。我的控制器、模型和视图代码如下。谢谢。
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; }
}
看法
@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>
}
控制器
[HttpPost]
public string EditUserActivity(UserActivity tempUserActivity)
{
string postedValue = tempUserActivity.ActionPerformed;
//When i debug this the "postedValue" is null
}