在asp.net mvc4(vb)

时间:2017-02-17 11:27:50

标签: asp.net-mvc vb.net dropdownlistfor

请在asp.net mvc4 VB中转换此代码

@Html.DropDownListFor(x => x.WillAttend, new[] 
{
new SelectListItem() {Text = "Yes, I'll be there", Value = bool.TrueString},
new SelectListItem() {Text = "No, I can't come", Value = bool.FalseString}
}, "Choose an option")

当我在VB中编写C#代码时,就像这样

@Html.DropDownListFor(Function(x) x.WillAttend, New SelectList( New SelectListItem With {.Text = "Yes, I'll be there", .Value = "p"}, New SelectListItem With {.Text = "No, I can't come", .Value = "p"})

我收到错误:无法转换类型为&System; System.Web.Mvc.SelectListItem'的对象输入' System.Collections.IEnumerable'。

1 个答案:

答案 0 :(得分:0)

@Html.DropDownListFor(Function(x) x.WillAttend, New SelectListItem() {New SelectListItem With {.Text = "Yes, I'll be there", .Value = Boolean.TrueString}, New SelectListItem With {.Text = "No, I can't come", .Value = Boolean.FalseString}}, "Choose an option")