TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ahmed salah
NA
530
148k
How to add dropdown YearID in current model section
Dec 1 2016 3:38 PM
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)
Reply
Answers (
1
)
Distribution number from Database sql randomly in 10 boxes
Delete records from three tables in sql server