Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
How to add dropdown YearID in current model section
ahmed salah
Dec 1 2016 3:38 PM
261
Reply
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)
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Distribution number from Database sql randomly in 10 boxes
Delete records from three tables in sql server