List<int> li = new List<int>(); for (int i = 20; i < 50; i++) { li.Add(i); } ViewData["j"] = new SelectList(li);
<%=Html.LabelFor(Model=>Model.age) %> <%=Html.DropDownList("j")%>
public class details { [DisplayName("Age")] public int age { get; set; } }
In View You have to do something like this
@Html.DropdownListFor(Model=>Model.age,new SelectListItem{@ViewBag.j,DataFieldId,DataFieldValue},"Select Text");
i have shown you genral format,use like this. This will surely help you.
<![CDATA[<%=Html.DropDownList(Model=>Model.age)%>]]>
public Actionview PostAction(Model model) { //selected combobox value int age = model.age; }
var value1 = Request["SimpleProp1"]; var value2 = Request["SimpleProp2"]; var value3 = Request["ComplexProp1.SimpleProp1"];
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)