[英]How to use System.Web.Mvc.SelectListItem
如何将ASP.NET MVC控制器使用System.Web.Mvc.SelectListItem。
1.Wrote SelectItemList collection generate code in Controller/Action method. 1.Write SelectItemList集合以Controller / Action方法生成代码。
ViewData["list"] = new List<SelectListItem>
{
new SelectListItem {Text = "January", Value = "1"},
new SelectListItem {Text = "February", Value = "2"},
new SelectListItem {Text = "March", Value = "3"}
};
2.Wrote render code in Views aspx. 2.在Views aspx中编写渲染代码。
<% using (Html.BeginForm()) { %>
<% = Html.DropDownList("list") %>
<input type="submit" value="send" />
<% } %>
3.Get posted value code in Controller/Action method with ModelBinder. 3.使用ModelBinder在Controller / Action方法中获取过帐值代码。
[HttpPost]
public ActionResult Index(string list)
{
// process code
}
How about this code? 这个代码怎么样? Best,regard.
最良好的问候。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.