码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2016-12-05 19:04:53      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:opd   select   collect   trim   val   pre   nbsp   log   drop   

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

}

 

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

标签:opd   select   collect   trim   val   pre   nbsp   log   drop   

原文地址:http://www.cnblogs.com/D-sD/p/6134785.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!