0

I have just started to learn 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?

1 Answer 1

8

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")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.