Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKyle Manson-Kullin
4,767 PointsAm I calling the Htlm.DropDownListFor method incorrectly?
Every time I hit Check Work I am met with a response of:
"Bummer: Did you replace the 'DepartmentId' field's Html.TextBoxFor method call with a call to the Html.DropDownListFor HTML helper method?"
Can anyone spot an obvious, silly mistake that I'm making?
@model IssueReporter.Models.Issue
@{
ViewBag.Title = "Report an Issue";
}
<h2>@ViewBag.Title</h2>
@using (Html.BeginForm())
{
<div>
@Html.LabelFor(m => m.Name)
@Html.TextBoxFor(m => m.Name)
</div>
<div>
@Html.LabelFor(m => m.Email)
@Html.TextBoxFor(m => m.Email)
</div>
<div>
@Html.LabelFor(m => m.DepartmentId)
@Html.DropDownListFor(m => m.DepartmentId, (SelectList)ViewBag.DepartmentsSelectListItem)
</div>
<div>
@Html.LabelFor(m => m.Severity)
@Html.TextBoxFor(m => m.Severity)
</div>
<div>
@Html.LabelFor(m => m.Reproducible)
@Html.TextBoxFor(m => m.Reproducible)
</div>
<div>
@Html.LabelFor(m => m.DescriptionOfProblem)
@Html.TextAreaFor(m => m.DescriptionOfProblem)
</div>
<button type="submit">Save</button>
}
1 Answer
Steven Parker
231,261 PointsIt's a spelling error, the instructions say to use ViewBag.DepartmentsSelectListItems (plural) but this code has "ViewBag.DepartmentsSelectListItem" (singular).
Kyle Manson-Kullin
4,767 PointsKyle Manson-Kullin
4,767 PointsThank you once again Steven. I knew it was a silly mistake.