ASP.NET MVC中,前台DropDownList传值给后台。

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();

}

 

posted @ 2016-12-05 17:32  AiKier  阅读(387)  评论(0)    收藏  举报