我想有这关系到一个对象+对象的财产清单相关手柄修改
前一种形式:名称和每个x项目:是否激活/价格
注:我知道项目的数量,它与另一个表有关。所有数据都可以由用户编辑。
我该如何用ASP .Net MVC实现这一目标?
public class AddChargeModel
{
[Required]
[Display(Name = "Name")]
public string Nom { get; set; }
[Required]
public List<ChargeLotModel> ChargeLot;
}
public class ChargeLotModel
{
[Required]
[Display(Name = "IdLot")]
public int IdLot { get; set; }
[Display(Name = "Price")]
public decimal Price { get; set; }
[Display(Name = "Active")]
public bool Active { get; set; }
}
我类AddChargeModel我的观点联系起来:
当我点击该按钮,然后在我的控制器功能输入:
[HttpPost]
public ActionResult Add(AddChargeModel model)
{
...
}
model.Name充满但不是model.ChargeLot == null。
数组中的控件在网页上被命名为ChargeLot_0__Price。 (如果我很好理解,它应该可以工作)
您是否有解决方案使其工作?
这是在这个线程讨论,一起来看看:http://stackoverflow.com/questions/11267354/how-to-produce-non-sequential-prefix-collection-indices-with -mvc-html-editor-tem/11267659#11267659 – MiBu