I have a drop down list in C# asp.net MVC3 razor engine. I need to load values to that dropdownlist from one of my tables in my database and some values are hard coded. So I need to get both kind of values into one dropdown list.
我可以分开做
我的看法是这样的:
@Html.DropDownListFor(model => model.MyTransaction.Status, new MultiSelectList(ViewBag.MyStatusId, "ID", "Name"))
我的模型 创建 enums 创建 :
public enum Ntypes{
halfday
casual
}
我的主计长:
ViewBag.MyTransaction = db.LeaveTypes.ToList(); //get the table values to drop down
这样我就能分开 硬编码的数值............
ViewBag.MyTansaction = (from NewLeaveTypes t in Enum.GetValues(typeof(Ntypes))
select new { ID = t, Name = t.ToString()).ToList();
But cant get both values into one dropdownlist. Plzzzz Help.
谢谢...