List<SelectListItem> ZH = new List<SelectListItem>(); ZH.Add(new SelectListItem { Text = "ZH1", Value = "ZH1" }); ZH.Add(new SelectListItem { Text = "ZH2", Value = "ZH2" }); ZH.Add(new SelectListItem { Text = "ZH3", Value = "ZH3" });
然后
<%= ViewData["ddl"] = ZH %>
最后展示
<%=Html.DropDownList("ddl")%>
后台通过Post,FormCollection取出数据
public ActionResult Index(FormCollection collection) { string zh = collection["ddl"] == null ? "" : collection["ddl"].Trim(); }
时间: 2024-12-28 18:42:59