2011-08-21 87 views
0

我刚刚开始学习ASP.NET MVC 3的形式this的书,我从它的例子有问题。ASP.net MVC 3错误:CS0103

我总是得到这个错误

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

下面是代码:

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

任何人知道如何解决这个问题?

回答

8

您忘记一些{}

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

不能相信我做出了这样的琐碎的错误,THX – Daniel