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
How to bind data to Drop Down List in asp.net mvc3
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
SenthilkumarRank #387 · 6.5K pointsPosted Apr 27, 2012, 1:15 AM EDT
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.
srujana gudla24 pointsPosted Apr 27, 2012, 1:31 AM EDT
I want to develop this app using Entity frame work
srujana gudla24 pointsPosted Apr 27, 2012, 4:08 AM EDT
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 }) %>
<% } %>