I'm looking at the new version of ASP.NET MVC (see here for more details if you haven't seen it already) and I'm having some pretty basic trouble displaying the content of an object.
In my control I have an object of type "Person", which I am passing to the view in ViewData.Model. All is well so far, and I can extact the object in the view ready for display. What I don't get, though, is how I need to call the Html.DisplayFor() method in order to get the data to screen. I've tried the following...
<%
MVC2test.Models.Person p = ViewData.Model as MVC2test.Models.Person;
%>
// snip
<%= Html.DisplayFor(p => p) %>
but I get the following message:
CS0136: A local variable named 'p' cannot be declared in this scope because it would give a different meaning to 'p', which is already used in a 'parent or current' scope to denote something else
I know this is not what I should be doing - I know that redefining a variable will producte this error, but I don't know how to access the object from the controller. So my question is, how do I pass the object to the view in order to display its properties?
(I should add that I am reading up on this in my limited spare time, so it is entirely possible I have missed something fundamental)
TIA