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
Gaurav Kapahi
NA
182
0
Cascading DropdownList With MVC razor Entity frame work
Sep 6 2013 12:40 AM
Please give me sample code or correct my code if any one have solution for how to make Cascade dropdown list with MVC razor by using entity framework. My code is
Controller:
public ActionResult Index(string MatchTypeName, string CompetitionName, string MatchName, string GroundName, string ReportName)
{
foreach (WebReportType WebRepots in db.WebReportTypes)
{
SelectListItem selectReportType = new SelectListItem
{
Text = WebRepots.ReportName,
Value = WebRepots.ReportName,
};
SelectReports.Add(selectReportType);
ViewBag.ReportName = SelectReports;
}
foreach (MatchTypeMaster MatchType in db.MatchTypeMasters)
{
SelectListItem selectMatchTypes = new SelectListItem
{
Text = MatchType.MatchTypeName,
Value = MatchType.MatchTypeID,
};
selectMatchTypeList.Add(selectMatchTypes);
ViewBag.MatchTypeName = selectMatchTypeList;
}
foreach (Competition CompMatchType in db.Competitions)
{
SelectListItem selectCompetitionTypes = new SelectListItem
{
Text = CompMatchType.CompetitionName,
Value = CompMatchType.CompetitionID,
};
selectCompetitionList.Add(selectCompetitionTypes);
ViewBag.CompetitionName = selectCompetitionList;
}
foreach (Match Match in db.Matches)
{
SelectListItem selectMatch = new SelectListItem
{
Text = Match.MatchName,
Value = Match.MatchID,
};
selectMatchList.Add(selectMatch);
ViewBag.MatchName = selectMatchList;
}
foreach (Ground Ground in db.Grounds)
{
SelectListItem selectGround = new SelectListItem
{
Text = Ground.GroundName,
Value = Ground.GroundID,
};
selectGroundList.Add(selectGround);
ViewBag.GroundName = selectGroundList;
}
View:
@Html.DropDownList("ReportName", ViewData["ReportName"] as MultiSelectList, new { multiple = "multiple", @class = "multiselect" , style = "width: 400px"})
@Html.DropDownList("MatchName", ViewData["MatchName"] as MultiSelectList, new { multiple = "multiple", @class = "multiselect" , style = "width: 400px"})
@Html.DropDownList("MatchTypeName", ViewData["MatchTypeName"] as MultiSelectList, new { multiple = "multiple", @class = "multiselect" })
Reply
Answers (
2
)
web service
Collections and generics in c#