1. The specialized collection SelectItemList generates code in the Controller / Action method.
ViewData["list"] = new List<SelectListItem>
{
new SelectListItem {Text = "January", Value = "1"},
new SelectListItem {Text = "February", Value = "2"},
new SelectListItem {Text = "March", Value = "3"}
};
2.Read the rendering code in aspx views.
<% using (Html.BeginForm()) { %>
<% = Html.DropDownList("list") %>
<input type="submit" value="send" />
<% } %>
3. Enter the value code in the Controller / Action method with ModelBinder.
[HttpPost]
public ActionResult Index(string list)
{
}
How about this code? The best as regards.
source
share