Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Creating a dropdownlist c# mvc3
- <% List<string> foo = new List<string>();
- foo.Add("Showing");
- foo.Add("ComingSoon);"
- foo.Add("Out");
- Html.DropDownList(foo, Model.Status); %>
- Html.DropDownList("Status",
- new SelectListItem[]{ new SelectListItem{ Text= "Showing", Value="Showing"},
- //same for others
- });
- <%: Html.DropDownListFor(model=> model.Status,
- new List<SelectListItem>() {
- new SelectListItem{ Text= "Showing", Value="Showing"},
- new SelectListItem{ Text= "ComingSoon", Value="ComingSoon"},
- new SelectListItem{ Text= "Out", Value="Out"}
- }); %>
- @{
- List<KeyValuePair<int, string>> dropdownList =
- new List<KeyValuePair<int, string>>();
- dropdownList.Add(new KeyValuePair<int, string>(0,"Showing"));
- dropdownList.Add(new KeyValuePair<int, string>(1,"ComingSoon"));
- dropdownList.Add(new KeyValuePair<int, string>(2,"Out"));
- SelectList selectList = new SelectList(dropdownList, "key", "value", 0);
- }
- @Html.DropDownList("foo", selectList)
Advertisement
Add Comment
Please, Sign In to add comment