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;
}
@Html.DropDownList("listname",ViewBag.drList as SelectList,"请选择",new {@class="mylist",@id="listID"})
时间: 2024-10-03 23:26:38