C# ASP.NET MVC Forms Improving Our Form Drop Down Lists

I can't see any similarities bettween the video and the challenge or find a method to do this.

I see some similarities but then the request in the challenge will be different enough or mix language and steps that I can't figure out where to start.

Report.cshtml
@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.DepartmentSelectListItems)
    </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>
}

3 Answers

Steven Parker
Steven Parker
148,894 Points

It looks like you understood what to do, you just made two small errors as you did it:

  • you forgot to remove the original closing parenthesis when you added the 2nd argument
  • you wrote "DepartmentSelectListItems" (missing a letter "s") instead of "DepartmentsSelectListItems"

Thanks. I got it!

Thanks!