您始终可以使用复选框值来指示是否删除该项目。
此值的名称将与您的 Product 类中的属性相关。
<form>
<% for(int i = 0; i < products.Count) { %>
<div>
<input type="hidden" name='<%=string.Format("products[{0}].Property1", i) %>' value='<%= products[i].Property1 %>' />
<input type="hidden" name='<%=string.Format("products[{0}].Property2", i) %>' value='<%= products[i].Property2 %>' />
<input type="hidden" name='<%=string.Format("products[{0}].Property3", i) %>' value='<%= products[i].Property3 %>' />
<input type="checkbox" name='<%=string.Format("products[{0}].ToDelete", i) %>' value='true' />
</div>
<% } %>
</form>
然后,当您到达 Delete() 时,您可以执行以下操作:
products = products.Where(x=>x.ToDelete == false).ToList();