0
我有这个选择,我需要将其转换为DropDownlistFor调用。转换选择DropDownListFor MVC 5
谁能帮帮忙:
<select class="form-control" name="QuestionBasicSection.Questions[@counter].ANSWER_LOOKUP_OPTION_ID" id="@selectId">
@foreach (var x in questionBasicSection.Questions[j].LookupGroup)
{
<option value="@x.Value" selected="@x.Selected">@x.Text</option>
}
</select>
这里是一个骨架,我只是不知道如何设置选择列表的,选择的值
@Html.DropDownListFor(q => questionBasicSection.Questions[@counter].ANSWER_LOOKUP_OPTION_ID,
new SelectList(
new List<Object>{
new { value = 0 , text = "Red" },
new { value = 1 , text = "Blue" },
new { value = 2 , text = "Green"}
},
"value",
"text",
// Not sure how to set selected
)