HtmlHelper DropDownListFor error,

Noitialonnold

New Member
I'm trying to learn MVC 4, and have had about a year of ASP.NEt development experience and about a year and a half of C# experience (both on my own time, not with an employer). Now that I'm employed, my workplace requires me to know MVC 4 (although not using Razor, to make things more complicated...). At any rate, I'm following along with Adam Freeman's "Pro ASP.NET MVC 4" book, and on pages 32 and 33 it has the following code for the RsvpForm.cshtml View:\[code\]<body><div> @Using (Html.BeginForm()) <p>Your name: @Html.TextBoxFor(x => x.Name)</p> <p>Your email: @Html.TextBoxFor(x => x.Email)</p> <p>Your phone: @Html.TextBoxFor(x => x.Phone)</p> <p>Will you attend? @Html.DropDownListFor(x => x.WillAttend, new [] { new SelectedListItem() {Text = "Yes, I'll be there.", Value = http://stackoverflow.com/questions/14568586/bool.TrueString}, new SelectedListItem() {Text ="No, I can't come.", Value = http://stackoverflow.com/questions/14568586/bool.FalseString}, },"Choose an option") </p> <input type="Submit" value="http://stackoverflow.com/questions/14568586/Submit RSVP" /> }</div>\[/code\]Yet, no matter what I do, the \[code\]SelectedListItem()\[/code\] returns an error:\[quote\] "The type or namespace name 'SelectedListItem' could not be found (are you missing a using directive or assembly reference?)"\[/quote\]I've checked and re-checked everything. The Controller has a minimal \[code\]ViewResult\[/code\] \[code\]RsvpForm()\[/code\] that returns the View, and the Model exposes the four public methods (Name, Email, Phone, WillAttend), as well as having a using directive for \[code\]System.Web.Mvc\[/code\] up top.would anyone mind helping me? I couldn't find a listing for errata on the APress site - only a location to submit it, so I'm not quite sure something is wrong or not.
 
Back
Top