1
kendo dropdownlistfor在下拉菜單中顯示準確的未定義記錄數,但不顯示項目名稱。請在這方面有所幫助,謝謝綁定Kendo DropDownListFor
**Controller**
var cdd = db.Items.Select(x => new
{
x.ItemID,
x.ItemName
}).ToList();
var viewmodel= new Accounting.DAL.Item();
var selec = new SelectList(cdd, "ItemID", "ItemName");
viewmodel.ItemsDrop = selec;
return View(viewmodel);
**Model**
public SelectList ItemsDrop { get; set; }
**View**
@(Html.Kendo()
.DropDownListFor(m => m.ItemName)
.Name("ItemName")
.DataTextField("ItemName")
.DataValueField("ItemID")
.BindTo(Model.ItemsDrop)
)