나는 아래와 같이 Html.ListBoxFor와 MVC 2.0을 사용하고 있습니다에 대해 정의 된 매개 변수가없는 생성자 : System.MissingMethodException :이 객체
<% using (Html.BeginForm()) { %>
<input type="submit" value=">" />
<%= Html.ListBoxFor(x => x.lstTest, new MultiSelectList(new [] {"someone", "crap", "why"})) %>
<% } %>
내가 입력을 클릭
가 아무것도 선택 아래 버튼을 제출, 그것은 다시 게시 좋아, 목록 상자에서 3 개의 항목 중 하나를 선택하면이 오류가 발생합니다.System.MissingMethodException: No parameterless constructor defined for this object.
아이디어가 있으십니까? 여기에 내 컨트롤러 코드 :
[HandleError]
public class HomeController : Controller
{
public HomeController()
{
}
public ActionResult Index()
{
ViewData["Message"] = "Test Harness";
return View();
}
[HttpGet]
public ActionResult About()
{
ViewData["mykey"] = "Test Harness";
LogOnModel model = new LogOnModel();
model.lstTest = new MultiSelectList(new [] {"A", "B", "C"});
return View(model);
}
[HttpPost]
public ActionResult About(LogOnModel model)
{
ViewData["mykey"] = "Test Harness";
model.lstTest = new MultiSelectList(new [] { "" });
return View(model);
}
}
안녕하세요, 내 컨트롤러에 매개 변수가없는 public 생성자가 있습니다. 다른 방법이 있습니까? – Whyyy
컨트롤러 코드를 게시 할 수 있습니까? –
위에 게시 됨, 감사합니다. – Whyyy