DropList
Controller:
1 //================下拉框 start=======================================
2 List<SelectListItem> dropDownLists = new List<SelectListItem>();
3 SelectListItem dropDownList1 = new SelectListItem();
4 dropDownList1.Text = "Text Test1";
5 dropDownList1.Value = "Text Value1";
6 dropDownLists.Add(dropDownList1);
7
8 SelectListItem dropDownList2 = new SelectListItem();
9 dropDownList2.Text = "Text Test2";
10 dropDownList2.Value = "Text Value2";
11 dropDownLists.Add(dropDownList2);
12 ViewData["DropDownList"] = dropDownLists;
13 //================下拉框 end==========================================
2 List<SelectListItem> dropDownLists = new List<SelectListItem>();
3 SelectListItem dropDownList1 = new SelectListItem();
4 dropDownList1.Text = "Text Test1";
5 dropDownList1.Value = "Text Value1";
6 dropDownLists.Add(dropDownList1);
7
8 SelectListItem dropDownList2 = new SelectListItem();
9 dropDownList2.Text = "Text Test2";
10 dropDownList2.Value = "Text Value2";
11 dropDownLists.Add(dropDownList2);
12 ViewData["DropDownList"] = dropDownLists;
13 //================下拉框 end==========================================
View:
1 <%=Html.DropDownList("DropDownList", (List<SelectListItem>)ViewData["DropDownList"], new { @onclick = "dbClick(this)" })%>
RadioButton