無(wú)法訪問(wèn) cshtml 頁(yè)面中的模型列表類型變量。這是我的模型類public class MBilling{ public List<string> plist { get; set; } public List<decimal> qlist { get; set; } public List<decimal> splist { get; set; }}控制器public ActionResult Billing(){ if (Session["UserId"] != null) { MBilling binddata = BillingService.getBindData(); return View(binddata); } else { return this.RedirectToAction("Index", "Login"); }}這是cshtml部分@model IEnumerable<Shop.Models.MBilling>@{ ViewBag.Title = "Billing";}<input style="border:none" list="browsers" name="browser"><datalist id="browsers"> ///Unable to ACCESS Model.plist @foreach (var item in Model.plist) { }</datalist>我能夠從服務(wù)文件中獲取具有所需數(shù)據(jù)的模型對(duì)象,但在 cshtml 頁(yè)面中顯示錯(cuò)誤CS1061:“ IEnumerable<MBilling>”不包含“ ”的定義,plist并且找不到接受“ ”類型的第一個(gè)參數(shù)的擴(kuò)展方法“plist” IEnumerable<MBilling>(您是否缺少 using 指令或程序集引用?)提前致謝。
1 回答

狐的傳說(shuō)
TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超3個(gè)贊
問(wèn)題:
您將模型作為類型對(duì)象返回,但在視圖中MBilling
使用它。IEnumerable<MBilling>
解決方案:
你不需要IEnumerable<T>
在這里,因?yàn)樗皇?em>enumerable。所以刪除它并執(zhí)行以下操作:
@model Shop.Models.MBilling
- 1 回答
- 0 關(guān)注
- 139 瀏覽
添加回答
舉報(bào)
0/150
提交
取消