請你能幫助我理解很簡單的事情
我有模型,我的課:
public class VendorAssistanceViewModel
{
public string Name { get; set; }
public bool Checked { get; set; }
}
public partial class CSModel : IEntity
{
public CSModel()
{
VendorAssistances = new[]
{
new VendorAssistanceViewModel { Name = "DJ/BAND" },
new VendorAssistanceViewModel { Name = "Officiant" },
new VendorAssistanceViewModel { Name = "Florist" },
new VendorAssistanceViewModel { Name = "Photographer" },
new VendorAssistanceViewModel { Name = "Videographer" },
new VendorAssistanceViewModel { Name = "Transportation" },
}.ToList();
}
public IList VendorAssistances { get; set; }
我有看法:
@model IEnumerable<CSTS.Models.CSModel>
//some html code...
我想知道如何顯示從型號複選框,使用VendorAssistances的陣列? 我知道這很簡單,我看了很多文檔,但還是不明白
謝謝!
修訂
我嘗試做如下:
分爲對照組在
public override ActionResult Index(int pageNumber, int pageSize, string nothing) { List<VendorAssistanceViewModel> VendorAssistances = new[] { new VendorAssistanceViewModel { Name = "DJ/BAND" }, new VendorAssistanceViewModel { Name = "Officiant" }, new VendorAssistanceViewModel { Name = "Florist" }, new VendorAssistanceViewModel { Name = "Photographer" }, new VendorAssistanceViewModel { Name = "Videographer" }, new VendorAssistanceViewModel { Name = "Transportation" }, }.ToList();
我已經添加了手錶VendorAssistances並插入斷點,所有的時間tihs對象爲NULL
爲什麼?
爲什麼使用CSModel的部分類? – Mohanraja
http://www.c-sharpcorner.com/uploadfile/4d9083/creating-simple-checkboxlist-in-mvc-4-using-razor/ –
不幸的是可以回答,這是一個ASP.NET網站的代碼,並且需要在此處做一些更改 – Fullbalanced