-1
我想在動態下拉列表的末尾使用MVC C#添加額外選項名稱Other
。當下拉菜單中加載數據時,在下拉列表的末尾總是會有一個額外的選項Other
。如何在動態下拉列表中添加額外選項列表末尾
public static List<SelectListItem> GetSubjects() {
try {
var subjectList = HelperMethods.ListofEntity<Subject>().Select(t => new SelectListItem {
Text = t.SubjectName,
Value = Convert.ToString(t.ID)
}).ToList();
return subjectList;
} catch (System.Exception ex) {
throw ex;
}
}
的只是將它加入 - 'subjectList.Add(新SelectListItem(){值= ....});' –