In my MVC
application how can bind the foreign key/relational
data in dropdownlist
for the following scenario.
While showing particular course details, ALL course category should get filled and CourseCategoryID of the course should set to selected
I have created model
like follow, but dropdown is filled only with the ONE value and not the entire list of course category ?
public partial class Course
{
[Key]
public int CourseID { get; set; }
public int CourseCategoryID { get; set; }
public string CourseDesciption { get; set; }
public string CourseTitle { get; set; }
[ForeignKey("CourseCategoryID")]
public virtual CourseCategory CourseCategory { get; set; }
}
public partial class CourseCategory
{
public CourseCategory()
{
Course = new HashSet<Course>();
}
[Key]
public int CourseCategoryID { get; set; }
public string CourseCategoryName { get; set; }
public virtual ICollection<Course> Course { get; set; }
}
and what I need to do on View
side ?