var r = new List<Vendor>()
{
new Vendor() {VendorId = 1, Name = "a"},
new Vendor() {VendorId = 2, Name = "b"},
new Vendor() {VendorId = 3, Name = "c"},
new Vendor() {VendorId = 4, Name = "d"},
new Vendor() {VendorId = 5, Name = "e"},
};
//将Vendor的数据封装到 SelectList中,制定要生成下拉框选项的value和text属性
SelectList selList1 = new SelectList(r, "VendorId", "Name", 0);
//把生成的集合放到ViewData中
ViewData["Categories"] = selList1;
@Html.DropDownList("myselect", (SelectList)ViewData["Categories"], "--请选择供应商--")
@* @Html.DropDownListFor(a => a.CategoryName, (SelectList)ViewData["Categories"], "--Select One--", new { @class = "dropdownlist" })*@
{
new Vendor() {VendorId = 1, Name = "a"},
new Vendor() {VendorId = 2, Name = "b"},
new Vendor() {VendorId = 3, Name = "c"},
new Vendor() {VendorId = 4, Name = "d"},
new Vendor() {VendorId = 5, Name = "e"},
};
//将Vendor的数据封装到 SelectList中,制定要生成下拉框选项的value和text属性
SelectList selList1 = new SelectList(r, "VendorId", "Name", 0);
//把生成的集合放到ViewData中
ViewData["Categories"] = selList1;
@Html.DropDownList("myselect", (SelectList)ViewData["Categories"], "--请选择供应商--")
@* @Html.DropDownListFor(a => a.CategoryName, (SelectList)ViewData["Categories"], "--Select One--", new { @class = "dropdownlist" })*@