Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7009301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:50:41+00:00 2026-05-27T21:50:41+00:00

I am trying to pass an object of model class for edit but receing

  • 0

I am trying to pass an object of model class for edit but receing this error “The model item passed into the dictionary is of type ‘System.Collections.Generic.List`1[MvcApplication1.Models.ResturantReviews]’, but this dictionary requires a model item of type ‘MvcApplication1.Models.ResturantReviews’.”

Kindly guide me where I am wrong, here is my code:

My Model class:

namespace MvcApplication1.Models{
public class ResturantReviews
{

        public int ReviewId { get; set; }
        public int Rating { get; set; }
        public string ReviewBody { get; set; }
        public Resturant Resturant { get; set; }

}

}

My Action code:

public ActionResult Edit(int Id)
    {
        //var review = FoodDB.review;
        ResturantReviews obj = new ResturantReviews {
          ReviewId = 2,
            Rating = 9,
            ReviewBody = "Test Sarina is a good resturant for continantal food",
            Resturant = new Resturant
            {
                ResturantId = 1,
                ResturantAddress = "Commercial area",
                ResturantName = "Sarina Hotel"

            }
        };



        return View(obj);
    }

My code in View:

@model MvcApplication1.Models.ResturantReviews

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>ResturantReviews</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.ReviewId)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.ReviewId)
            @Html.ValidationMessageFor(model => model.ReviewId)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Rating)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Rating)
            @Html.ValidationMessageFor(model => model.Rating)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.ReviewBody)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.ReviewBody)
            @Html.ValidationMessageFor(model => model.ReviewBody)
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:50:41+00:00Added an answer on May 27, 2026 at 9:50 pm

    The Edit controller action (as shown in your question) passes a single instance of ResturantReviews and the view is strongly typed to @model ResturantReviews so this should not throw an exception. The code seems correct as is.

    So you could try narrowing down by simplifying at maximum:

    public ActionResult Edit(int Id)
    {
        var model = new ResturantReviews();
        return View(model);
    }
    

    and the Edit.cshtml view:

    @model ResturantReviews
    @Html.BeginForm()
    {
        <p>
            <input type="submit" value="Save" />
        </p>    
    }
    

    This should work 100%. Then you could start adding functionality.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find the actual class of a django-model object, when using model-inheritance.
Trying to edit object permissions using django-guardian in the admin site I get this
I'm trying to pass an object from one controller action to another. The object
I'm trying to pass a complex object (that can be serialized, if that helps)
I'm trying to pass a ViewData object from a master page to a view
I'm trying to pass a business object from one WinForm to another WinForm for
I'm trying to pass a JavaScript object to a PHP script through jquery.ajax() ,
I'm trying to return a reference to an object, not pass it by value.
I am trying to pass a member function within a class to a function
I'm trying to pass in a Base64 string into a C#.Net web application via

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.