public ActionResult Index()
{
List<SelectListItem> items = new List<SelectListItem>()
{
new SelectListItem(){Text="Income", Value="income"},
new SelectListItem(){Text="Outcome", Value="outcome"},
};
SelectList generateList = new SelectList(items, "Value", "Text");
ViewBag.drList = generateList;
}
{
List<SelectListItem> items = new List<SelectListItem>()
{
new SelectListItem(){Text="Income", Value="income"},
new SelectListItem(){Text="Outcome", Value="outcome"},
};
SelectList generateList = new SelectList(items, "Value", "Text");
ViewBag.drList = generateList;
}
@Html.DropDownList("listname",ViewBag.drList as SelectList,"请选择",new {@class="mylist",@id="listID"})