2012-11-25 4 views
0

나는 this one 유사 드롭 다운 메뉴의 모델이있다. 나는 그것을위한 컨트롤러를 만들려고 노력하고있다.MVC3 드롭 다운 메뉴 컨트롤러

public ActionResult Index() 
    { 
     ViewBag.Message = "Welcome to ASP.NET MVC!"; 
     return View(new MyData()); 
    } 

그리고 나는이

@Html.DropDownListFor(m => m.State, 
new SelectList(Model.StateList, "Value", "Text")) 

처럼 내보기를 생성하지만 위의 라인 아래의 오류가 발생하고있다 : 당신은 내가 잘못 뭐하는 거지 내가 직접시겠습니까

Compiler Error Message: CS1061: 'System.Collections.Generic.List<Projects.Models.MyData>' does not contain a definition for 'StateList' and no extension method 'StateList' accepting a first argument of type 'System.Collections.Generic.List<Projects.Models.MyData>' could be found (are you missing a using directive or an assembly reference?) 

?

+0

MyData를 어떻게 정의 했습니까? –

+0

MyData는 링크에 제공된 것과 매우 비슷합니다. – jpo

+0

보기에서 모델 선언은 어떻습니까? –

답변

1

문제는 @model List<ProjectName.Models.MyData> 단순히

@model Projects.Models.MyData 

환호로 변경합니다!