【发布时间】:2020-12-09 20:01:28
【问题描述】:
我有一个在页面加载时创建并填充值的列表。提交页面后,我需要在 post 方法中使用列表中的这些值。
有没有办法为列表项做到这一点?
对于其他领域我这样做:
< input asp-for="FileID" type="hidden" />
但我在模型中有这个列表:
public List<String> DocumentListing { get; set; }
但是下面的两种尝试都不允许我在提交时看到控制器的 Post 方法中的列表项
int DocumentsCount = Model.DocumentListing.Count();
for (int i = 0; i < DocumentsCount; i++)
{
Model.DocumentListing.Add(Model.DocumentListing.ElementAtOrDefault(i));
<input asp-for="DocumentListing.ElementAtOrDefault(i)" type="hidden">
}
有人可以帮忙吗?
【问题讨论】:
标签: html forms asp.net-core-mvc