dynamic dropdown select list
-
I am newbie in asp.net Using EF , I am fetching movie type from db. Don't no how to display in dropdown as well as if movietype get edit using EF how it will show selected or saved dropdown selected value? code
@Html.DropDownListFor( m => m.Parent, new[] { @Value = newViewBag.MovieType } }
-
I am newbie in asp.net Using EF , I am fetching movie type from db. Don't no how to display in dropdown as well as if movietype get edit using EF how it will show selected or saved dropdown selected value? code
@Html.DropDownListFor( m => m.Parent, new[] { @Value = newViewBag.MovieType } }
-
Thanks for advice please let me know asp.net forum or any place here for help.thanks
-
I am newbie in asp.net Using EF , I am fetching movie type from db. Don't no how to display in dropdown as well as if movietype get edit using EF how it will show selected or saved dropdown selected value? code
@Html.DropDownListFor( m => m.Parent, new[] { @Value = newViewBag.MovieType } }
Hi, Here is the code that can be used on cshtml pages @Html.DropDownListFor(model => model.movietypeID, new SelectList(Model.movietypes, "Key", "value"), "--Select--") You need to bind the movietypes variable as a dictionary from the database. On the time of editing, you need to fetch the value of movie type selected at the time of creation and assign it to movietypeID, and again you will have to bind the movietypes variable from the database.