2011-08-21 3 views
0

Je viens de commencer à apprendre ASP.NET MVC 3 formulaire this livre et j'ai un problème avec l'exemple de celui-ci.ASP.net MVC 3 erreur: CS0103

Je reçois toujours cette erreur

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

Voici le 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") 

Quelqu'un sait comment résoudre ce problème?

Répondre

8

vous avez oublié une {}:

@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

ne peux pas croire que je fait une telle erreur triviale, thx – Daniel