I’ve got a list of objects that have a Name and a list of values and another property representing the SelectedValue.
I wanted to display the Name and then have a drop down – but not sure how to do it!
Can anyone assist please?
With the following example p.Name works, its the p.Values and p.SelectedValues bits that don’t!
<div id="gridProps">
<ul id="props">
@foreach (var p in Model.AvailableProperties)
{
<li>@p.Name : @Html.DropDownListFor(p.SelectedValue, p.Values)</li>
}
</ul>
</div>
I think what you are looking for is
@Html.DropDownListinstead of@Html.DropDownListFor@Html.DropDownListactually has the overload that you’re looking for:All of the
@Html.DropDownListForoverloads take anExpression<Func<...>>as the first parameter, and it doesn’t look like that’s what you’re passing in your call.