What I need
I need to add drop down YearID from model Year to
current model section with Formate bootstrap as (Replace departID WITH YearID)
I work in mvc 5 visual studio 2015 and i need to get drop down list from another model
Current model name is Section:
- namespace UniversityData.Models
- {
-
- [Table("Section")]
- public partial class Section
- {
- public Section()
- {
-
- }
-
-
- [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
-
- [Key]
-
- public int SecID { get; set; }
-
- [Required]
- [StringLength(50)]
- public string SecName{ get; set; }
-
- [ForeignKey("Department")]
- [DisplayName("DepartmentName")]
- public int departID { get; set; }
- }
- }
my code to drop down departID inside my current model section with bootstrap is :
class="form-group">
- @Html.LabelFor(model => model.departID, "DepartmentName", htmlAttributes: new { @class = "control-label col-md-2" })
-
class
="col-md-10"> - @Html.DropDownList("departID", null, htmlAttributes: new { @class = "form-control" })
- @Html.ValidationMessageFor(model => model.departID, "", new { @class = "text-danger" })
-
Another model Year I want to generate dropdown to it
- [Table("Year")]
- public partial class Year
- {
- public Year()
- {
- this.department = new HashSet();
-
- }
- [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
-
- [Key]
- public int YearID { get; set; }
- [Required]
- [StringLength(50)]
-
- public string YearName { get; set; }
-
- }
- }
What I need
I need to add drop down YearID from model Year to
current model section with Formate bootstrap as (departID BOOTSTRP dropdown)