How to use Lookup with a complex viewmodel

Dec 9, 2010 at 11:16 PM

It looks like the default helpers:  EditorFor, LookupFor, Lookup  wont work if your view uses a complex model.

This wont work: 


This kinda works:  


But, it generates the form field: PersonID instead of TeamMember.PersonID

Also tried this but no luck: 


Any ideas?

Dec 10, 2010 at 7:49 AM


Thnx for contributing

I did this today, you can either wait until the next release or

replace you Awesome folder with the one from the current source code


Dec 10, 2010 at 2:58 PM
Edited Dec 10, 2010 at 3:52 PM

Fantastic - that worked great!

You have to use:

Html.Lookup("TeamMember.PersonID", Model.TeamMember.PersonID, controller:"PersonIDLookup") 


EditorFor(model=>model.TeamMember.PersonID) - didnt do anything, maybe I needed to create a template?

Html.LookupFor(model => model.TeamMember.PersonID,controller:"PersonIDLookup") - showed the button, but didnt show the person on the edit screen.


Thanks for creating a great project of awesome features!

Dec 11, 2010 at 10:56 AM

in the demo from the source code in index.aspx for LookupDemoController I do:

    <%=Html.EditorFor(o => o.Team.ThePerson) %>

and it works, try running the demo