0

嗨,我正在尝试发布一个复杂的类,Witcht itzelf 拥有不同的复杂类

    public static readonly PropertyInfo<List<RoomsWithServices>> RoomsWithServicesListProperty = RegisterProperty<List<RoomsWithServices>>(c => c.RoomsWithServicesList);
    public List<RoomsWithServices> RoomsWithServicesList
    {
        get { return GetProperty(RoomsWithServicesListProperty); }
        set { SetProperty(RoomsWithServicesListProperty, value); }
    }

    public static readonly PropertyInfo<List<SelectableBookingService>> BookingServicesProperty = RegisterProperty<List<SelectableBookingService>>(c => c.BookingServices);
    public List<SelectableBookingService> BookingServices
    {
        get { return GetProperty(BookingServicesProperty); }
        set { SetProperty(BookingServicesProperty, value); }
    }

但是当我发布模型为空时,模型正确构建并显示正确的数据。但是当我尝试发布帖子给我的数据时是空的

@foreach (RoomsWithServices item in Model.RoomsWithServicesList)
{
    <div>
    @Html.HiddenFor(m => item.Room.VideoConferencingRoomId)
    @Html.DisplayFor(m => item.Room.Name)
    @Html.HiddenFor(m => item.Room.Name)
    @foreach (SelectableRoomService service in item.RoomService)
    {
        <div>
        @Html.EditorFor(m => service.IsSelected)| @Html.DisplayFor(m => service.RoomService.ServiceName) | @Html.DisplayFor(m => service.RoomService.Price)
        @Html.HiddenFor(m => service.RoomService.ServiceName) 
        @Html.HiddenFor(m => service.RoomService.Price)
        </div>
    }                                          
    </div>
}
</div>
<div>
<h2>BookingServies</h2>
@foreach (SelectableBookingService item in Model.BookingServices)
{
    <div>
    @Html.EditorFor(m => item.IsSelected)| @Html.DisplayFor(m => item.Service.Name) | @Html.DisplayFor(m => item.Service.Price)
    </div>
}
</div>

<input type="submit" name="RoomsWithServicesListAndBookingServices" value="Confirm Selected Services"/> 
</fieldset>

}

我怎么解决这个问题

谢谢

4

0 回答 0