Hi to Everyone
I searched a lot for the following but I didn't find the answer anywhere
I want to display data in first drop down list from database,when I select item from first drop down list again I want to display list of items from database into second drop down list in asp.net mvc3 app.
If anybody knows the answer please help me
Loading
srujana gudlaPosted Apr 27, 2012, 8:08 AM
but I need 1 only how to resolve this
here is my controller
private sampleEntities db = new sampleEntities();
public ActionResult Index()
{
var GenreLst = new List
var GenreQry = from d in db.emps
orderby d.name
select d.name;
GenreLst.AddRange(GenreQry.Distinct());
ViewBag.movieGenre = new SelectList(GenreLst);
return View(db.emps.ToList());
view:
}
Index
<%:ViewBag.Title="Index" %>
<%: Html.ActionLink("Create New", "Create") %>
name
<% foreach (var item in Model) { %>
<%:Html.DropDownList("movieGenre") %>
<%: Html.ActionLink("Edit", "Edit", new { id=item.Id }) %> |
<%: Html.ActionLink("Details", "Details", new { id=item.Id }) %> |
<%: Html.ActionLink("Delete", "Delete", new { id=item.Id }) %>
<% } %>
srujana gudlaPosted Apr 27, 2012, 5:31 AM
I want to develop this app using Entity frame work
SenthilkumarPosted Apr 27, 2012, 5:15 AM
There are plenty of articles in the online for the cascading drop down in asp.net mvc.
http://code.msdn.microsoft.com/Cascading-DropDownList-in-833683f9
http://geekswithblogs.net/ranganh/archive/2011/06/14/cascading-dropdownlist-in-asp.net-mvc-3-using-jquery.aspx
http://weblogs.asp.net/raduenuca/archive/2011/03/06/asp-net-mvc-cascading-dropdown-lists-tutorial-part-1-defining-the-problem-and-the-context.aspx
http://www.codeproject.com/Articles/350842/Cascading-DropDownList-in-ASP-NET-MVC
Hope this will help you.