You would like to add a drop down list box to your web page showing each department but your code below is only showing d.DepartmentName not the actual department name when you run your application. How can you change the code so it works correctly? @foreach (Department d in ViewBag.Departments)
7.
You would like to add a drop down list box to your web page showing each department but your code below is only showing d.DepartmentName not the actual department name when you run your application. How can you change the code so it works correctly?
@foreach (Department d in ViewBag.Departments)
{
<option value="d.DepartmentID">d.DepartmentName</option>
}
3. <option value="d.DepartmentID">d.DepartmentName</option> should be changed to:
<option value="d.DepartmentName">d.DepartmentName</option>
4. <option value="d.DepartmentID">d.DepartmentName</option> should be changed to:
<option value="@d.DepartmentID">@d.DepartmentName</option>
4. <option value="d.DepartmentID">d.DepartmentName</option> should be changed to:
<option value="@d.DepartmentID">@d.DepartmentName</
Step by step
Solved in 2 steps