提交modle到后台时获取不到值,全部为空。不知错在了哪?
1.后台返回一个列表给视图
return PartialView(lstProduct);
2.视图,可以看到绑定值成功
@model List
for (int i = 0; i < Model.Count; i++)
{
Product product = Model[i];
<form asp-controller="Controls" id="main" asp-action="UpdateProduct" method="post" data-ajax="true" data-ajax-begin="begin" data-ajax-primary="afterSuccess" data-ajax-complete="completed" data-ajax-failure="failed">
<table class="table table-borderless">
<tbody>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<input asp-for="@product .Name" type="text" value=@product .Name" class="form-control input-group input-group-lg" />
<input asp-for="@product .No" type="hidden" value="@product .No" />
</td>
</tr>
<tr>
<td><input type="reset" value="Cancel" class="form-control btn-secondary" /></td>
<td><input type="submit" value="Confirm" class="form-control btn-primary" /></td>
</tr>
}
3.提交处理时,获取所有字段均为空值
public async Task<IActionResult> UpdateProduct(Product Product)
{
}