Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I may be asking a question that a lot of programmers might have asked but still here it goes..

I have the a model User with following properties
C#
public string firstName { get; set; }
public string lastName { get; set; }
public string userName { get; set; }
public int userTypeID { get; set; }
public string email { get; set; }
public long phoneNumber1 { get; set; }
public long phoneNumber2 { get; set; }
public string address { get; set; }


In the model UserProfile() I load an object named user with a user's details as shown above and send it to the view as
C#
View(user);


And I have created a strongly typed view as

HTML
@model OnlineShoppingSystemMVC.Models.User
@{
    ViewBag.Title = "UserProfile";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>UserProfile</h2>
<fieldset>
    <legend>User</legend>
    <div class="display-label">
@Html.DisplayNameFor(model => model.firstName)
    </div>
    <div class="display-field">
@Html.DisplayFor(model => model.firstName)
    </div>
    .
    .
    </fieldset>
<p>
    @Html.ActionLink("Edit", "Edit", new { /* id=Model.PrimaryKey */ }) |
    @Html.ActionLink("Back to List", "Index")
</p>



When I execute the application and redirect to the view it showing the following error
The model item passed into the dictionary is of type 'OnlineShoppingSystemMVC.Models.User', but this dictionary requires a model item of type 'OnlineShoppingSystemMVC.Models.Repository'.

Can any one help out on where I went wrong?

Thanks for any support in advance.
Posted
Updated 30-Apr-14 22:44pm
v2
Comments
Sunasara Imdadhusen 1-May-14 6:35am    
can you please try this @model OnlineShoppingSystemMVC.Models.<user>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900