【发布时间】:2017-05-12 12:38:25
【问题描述】:
它可能会重复问题,我已经搜索过但不满意,所以我在这里发布问题。
我有对象(从实体框架生成),
public partial class Usp_Sel_NotEnteredStringResources_Result
{
public string name { get; set; }
public Nullable<int> Value { get; set; }
public int StringResourceId { get; set; }
public Nullable<int> LanguageId { get; set; }
}
和我创建的视图,
@{
ViewBag.Title = "Resource Entry Languagewise";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>ResourceEntry</h2>
@using (Html.BeginForm("ResourceEntry", "LangResource", FormMethod.Post))
{
<fieldset>
<table>
@for (int i = 0; i < Model.ToList().Count; i++)
{
<tr>
<td>@Html.DisplayFor(m => Model.ElementAt(i).name)</td>
<td>@Html.TextBoxFor(m => Model.ElementAt(i).Value)</td>
@Html.HiddenFor(m => Model.ElementAt(i).LanguageId)
@Html.HiddenFor(m => Model.ElementAt(i).name)
@Html.HiddenFor(m => Model.ElementAt(i).StringResourceId)
</tr>
}
</table>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
}
和控制器一样,
[HttpPost]
public ActionResult ResourceEntry(List<Usp_Sel_NotEnteredStringResources_Result> list)
{
// here getting the null value for list
// ??????
return View(list);
}
表单控制器提交后得到列表的空值,代码有什么问题??
【问题讨论】:
标签: entity-framework asp.net-mvc-4 razor