action:
public ActionResult Register()
{
var items = new List<SelectListItem>()
{
(new SelectListItem() {Text = "保密", Value = "0", Selected = true}),
(new SelectListItem() {Text = "男", Value = "1", Selected = false}),
(new SelectListItem() {Text = "女", Value = "2", Selected = false})
};
ViewData["items"] = items;
return View();
}
view:
<label for="sex">性别:</label>
<%=Html.DropDownList("items")%>