2017-02-17 55 views
-3

請轉換在asp.net mvc4 VB這個代碼添加項目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") 

當我寫上面的C#代碼在VB中像這樣

@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.Web.Mvc.SelectListItem'的對象類型轉換爲'System.Collections.IEnumerable'。

+1

什麼阻止你這樣做?你做了什麼嘗試,你卡在哪裏? – David

+0

你不能點這裏做點什麼。向我們展示您的努力 – Hemal

+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")