我想有這關係到一個對象+對象的財產清單相關手柄修改
前一種形式:名稱和每個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