我有這樣的模式:MVC模型列表結合
public class ReservationViewModel
{
public Flight InboundFlight { get; set; }
public Flight OutboundFlight { get; set; }
}
//Flight
public class Flight
{
public List<ISeat> Seats { get; set; }
}
//Seats
public interface ISeat
{
ECabin Cabin { get; }
int NumberOfSeatsAvailable { get; }
int SeatsChosen { get; set; }
string PropertyName { get; }
}
我的HTML組成的folliwing的:
<select id="OutboundFlight__0__Seats_SeatsChosen" name="OutboundFlight.[0].Seats.SeatsChosen" class="valid"><option...
<select id="OutboundFlight__0__Seats_SeatsChosen" name="OutboundFlight.[1].Seats.SeatsChosen" class="valid"><option...
<select id="OutboundFlight__0__Seats_SeatsChosen" name="OutboundFlight.[2].Seats.SeatsChosen" class="valid"><option...
我的行動:
[HttpPost]
public ActionResult Index(ReservationViewModel model, FormCollection form)
{
return View();
}
在提交我嘗試綁定回到模型,但每個航班的座位返回空... 幫助將不勝感激
您控制器的操作也會很有用 – glosrob
我不認爲這裏有足夠的信息來回答這個問題。 –