Skip to content
Advertisement

To add dropdownlist using a secondary table column values

I have to add a dropdownlist to my existing project “moviesite”, i have a primary table moviestable for adding, edit delete movies. now added a new table Genre to add movieGenre. second table consist of two column , “GenreId set as primarykey and identity , second column is name( consist of genre types like Action, drama ,comdey etc.) and added a column GenreRefId to primary table and set as Foreign-key. now i want to access the secondary table’s column for a dropdown in the main project. so i created a new model class “GenreClass.cs” and added it to dbcontext. now i am stucked with how to implement it in model,controller and index.

Advertisement

Answer

First-step fetch and List of Genres and set in a viewbag

second-step : bind into dropdown html

third-step : Add GenreRefId in Post Methode

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement