第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

請(qǐng)問(wèn)MVC表單無(wú)法發(fā)布對(duì)象列表

請(qǐng)問(wèn)MVC表單無(wú)法發(fā)布對(duì)象列表

海綿寶寶撒 2019-08-01 02:01:16
MVC表單無(wú)法發(fā)布對(duì)象列表所以我有一個(gè)MVC ASP.NET應(yīng)用程序有問(wèn)題。本質(zhì)上,我有一個(gè)視圖,它包含一個(gè)表單,它的內(nèi)容被綁定到一個(gè)對(duì)象列表中。在這個(gè)循環(huán)中,它加載PartialView中正在循環(huán)的項(xiàng)?,F(xiàn)在一切都在運(yùn)轉(zhuǎn),直到形體被提交。當(dāng)提交時(shí),控制器將被發(fā)送一個(gè)空對(duì)象列表。下面的代碼證明了這些問(wèn)題。家長(zhǎng)意見(jiàn):@model IEnumerable<PlanCompareViewModel>@using (Html.BeginForm("ComparePlans", "Plans", FormMethod.Post, new { id = "compareForm" })){<div>     @foreach (var planVM in Model)     {         @Html.Partial("_partialView", planVM)     }</div>}_ParalView:@model PlanCompareViewModel<div>     @Html.HiddenFor(p => p.PlanID)     @Html.HiddenFor(p => p.CurrentPlan)     @Html.CheckBoxFor(p => p.ShouldCompare)    <input type="submit" value="Compare"/></div>以下是上述代碼的類(lèi):PlanViewModel:public class PlansCompareViewModel{     public int PlanID { get; set; }     public Plan CurrentPlan { get; set; }     public bool ShouldCompare { get; set; }     public PlansCompareViewModel(Plan plan)     {         ShouldCompare = false;         PlanID = plan.PlanId;         CurrentPlan = plan;     }     public PlansCompareViewModel()     {         // TODO: Complete member initialization     }     public static IEnumerable<PlansCompareViewModel> CreatePlansVM(IEnumerable<Plan> plans)     {         return plans.Select(p => new PlansCompareViewModel(p)).AsEnumerable();     }}主計(jì)長(zhǎng):public class PlansController : MyBaseController{     [HttpPost]     public ActionResult ComparePlans(IEnumerable<PlanCompareViewModel> model)     {          //the model passed into here is NULL     }}問(wèn)題在于控制器的作用。據(jù)我所知,它應(yīng)該發(fā)布一個(gè)PlanCompareViewModel的可枚舉列表,但它是空的。在檢查發(fā)送的POST數(shù)據(jù)時(shí),它發(fā)送的是正確的Params。如果我要將‘IEnDigable’改為‘FormCollection’,它包含正確的值。有人知道為什么綁定器沒(méi)有創(chuàng)建正確的對(duì)象嗎?我可以使用javascript繞過(guò)這個(gè)問(wèn)題,但這違背了目的!任何幫助都將不勝感激!
查看完整描述

2 回答

  • 2 回答
  • 0 關(guān)注
  • 666 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)