Why does model binding not work in DropDown?
What am I doing wrong?
To illustrate my problem, I did the following:
Created a new asp.net MVC project (beta1) Created the following class:
HomeViewData : ViewDataDictionary
+List : SelectList
Added a view to the HomeController class, as shown below:
Homecontroller: Controller
+HomeViewData vd = new HomeViewData
The following lines have been added to my Home.Index () method
vd.list = new SelectList(new List<string>(){"test", "test1", "test2"});
return View("Index", vd);
And it will play the same method, but with a different signature to catch callbacks
[AcceptVerps(HttpVerbs.Post)]
public ActionResult Index(HomeViewdata d)
Here I added a breakpoint to the first line of code.
Then I added the following code to my Index.aspx
<%Html.BeginForm();%>
<%=Html.DropDownList("List")%>
<%Html.EndForm();%>
, test1 test2.
( ) , . HomeViewData...
NULL
, , , ...
- EDIT -
, :
- [ (Prefix = "")] , Phil
- [Bind (Prefix = ")], , " "