var data2 = newdb.Incident
.Where(a => a.Status != Status && a.Category != Category)
.OrderByDescending(a => a.StartTime)
.Skip(CurrentPage * pageSize)
.Take(pageSize);
return View(data2)
view
@model IEnumerable<Antarex.Web.EF.Incident>
@Html.DropdownList(????) how to fill the list with the item passed to the model i know that i can use a viewData but there si another way using the model?
moy7
Member
52 Points
86 Posts
pass model to the dropdownlist
Jul 20, 2012 07:45 PM|LINK
i have tis method in the controller:
var data2 = newdb.Incident
.Where(a => a.Status != Status && a.Category != Category)
.OrderByDescending(a => a.StartTime)
.Skip(CurrentPage * pageSize)
.Take(pageSize);
return View(data2)
view
@model IEnumerable<Antarex.Web.EF.Incident>
@Html.DropdownList(????) how to fill the list with the item passed to the model i know that i can use a viewData but there si another way using the model?
keivan mousa...
Member
156 Points
115 Posts
Re: pass model to the dropdownlist
Jul 20, 2012 07:56 PM|LINK
please try this example
public ActionResult Create() { var Query = kc.TypeOptics.AsQueryable(); var Select = new SelectList(Query.ToArray(), "Id", "Name"); ViewBag.TypeOptics = Select; return View(); }<%: Html.DropDownList("TypeOptics", ViewBag.TypeOptics as SelectList, "Please Select Item", new { id = "TypeOpticsID" })%>ricka6
All-Star
15070 Points
2272 Posts
Microsoft
Moderator
Re: pass model to the dropdownlist
Jul 20, 2012 09:52 PM|LINK
See my DDL tutorial http://www.asp.net/mvc/tutorials/javascript/working-with-the-dropdownlist-box-and-jquery/using-the-dropdownlist-helper-with-aspnet-mvc and http://blogs.msdn.com/b/rickandy/archive/2012/01/09/cascasding-dropdownlist-in-asp-net-mvc.aspx