Select List returns System.Data.Entity.DynamixProxies instead of values in MVC asp.net C#
asp.net, asp.net-mvc-3, c#, razor
Solution
You are using a wrong overload, use this instead:
@Html.DropDownListFor( x => x.ProjectDetail,
new SelectList(Model.ProjectDetail, "ProjectId","ProjectName"))
// where ProjectId is the unique identifier field of `ProjectDetail`
// and `ProjectName` is the text you want to show in the dropdown
In your code you are not telling the html helper what properties to use for the `datavalue` and the `datatext`. The overload you use is the one where you tell the htmlhelper which value is selected.
Problem
I have got two different tables. User and ProjectDetails. There are two different controllers as well to do CRUD operations on these tables. Now, I have a case where, in the User CREATE operation, I have to select the Project from the List of Projects in ProjectDetails. I tried the following: In the user model, I created this line: ``` public IEnumerable<ProjectDetail> ProjectDetail { get; set; } ``` And in the controller, in the create Action, I have added the following code: ``` public ActionResult Create() { var model = new UserDetail { ProjectDetail = db1.ProjectDetails }; return View(model); } ``` And in the create view, I am trying to get the list of Project IDs as follows: ``` @Html.DropDownListFor( x => x.ProjectDetail, new SelectList(Model.ProjectDetail, "Project ID")) ``` However, wen i run, i get the number of lines (as equal to the number of projects) as System.Data.Entity.DynamicProxies.ProjectDetails_F########### (Some numbers).. Please can someone help me? Regards, Hari [EDIT] - I checked in the debug mode and found the following.. Tried attaching the image.. I drilled down that Proxy things and found ProjectID there. How can I get that?