ASP.net MVC 3 error: CS0103
I have just started to l开发者_C百科earn ASP.NET MVC 3 form this book and I have a problem with example from it.
I always get this error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'Text' does not exist in the current context
Here is the code:
@Html.DropDownListFor(p => p.WillAttend, new[]
{
new SelectListItem(), Text = "Yes I'll be there", Value = bool.TrueString,
new SelectListItem(), Text = "No, I can't come", Value = bool.FalseString
}, "Chose option")
Anyone know how to solve this problem?
you forgot some {}
:
@Html.DropDownListFor(p => p.WillAttend, new[]
{
new SelectListItem(){ Text = "Yes I'll be there", Value = bool.TrueString},
new SelectListItem(){ Text = "No, I can't come", Value = bool.FalseString}
}, "Chose option")
精彩评论