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

  • Home
  • SEARCH
  • 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 3482564
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:34:26+00:00 2026-05-18T10:34:26+00:00

I’m a newbie and I tried finding a solution of this error message: The

  • 0

I’m a newbie and I tried finding a solution of this error message:

“The model item passed into the
dictionary is of type
‘NerdDinner.Controllers.DinnerFormViewModel’,
but this dictionary requires a model
item of type
‘NerdDinner.Models.Dinner'”

There are similiar problem error but not the same context problem.
I believe that the problem is located in the edit.aspx and still i can’t solve it.

DinnersController:

//
// GET: /Dinners/Create

public ActionResult Create()
{

    Dinner dinner = new Dinner()
    {
        EventDate = DateTime.Now.AddDays(7)
    };

    return View(new DinnerFormViewModel(dinner));
}

Models:

namespace NerdDinner.Models
{
    [MetadataType(typeof(Dinner_Validation))]
    public partial class Dinner
    {

    }

    public class Dinner_Validation
    {
        [Required(ErrorMessage = "Title is required")]
        [StringLength(50, ErrorMessage = "Title may not be longer than 50 characters")]
        public string Title { get; set; }

        [Required(ErrorMessage = "Description is required")]
        [StringLength(265, ErrorMessage =
          "Description must be 256 characters or less")]
        public string Description { get; set; }

        [Required(ErrorMessage = "Address is required")]
        public string Address { get; set; }

        [Required(ErrorMessage = "Country is required")]
        public string Country { get; set; }

        [Required(ErrorMessage = "Phone# is required")]
        public string ContactPhone { get; set; }
    }
}


namespace NerdDinner.Controllers
{
    public class DinnerFormViewModel
    {

        private static string[] _countries = new[] 
        {
            "USA",
            "Afghanistan",
            "Akrotiri",
            "Albania",
            //... omitted for brevity
            "Zimbabwe"
        };


        // Properties
        public Dinner Dinner { get; private set; }
        public SelectList Countries { get; private set; }

        // Constructor
        public DinnerFormViewModel(Dinner dinner)
        {
            Dinner = dinner;

            Countries = new SelectList(_countries, dinner.Country);
        }
    }
}

Edit.aspx:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<NerdDinner.Controllers.DinnerFormViewModel>" %>

<asp:Content ID="Title" ContentPlaceHolderID="TitleContent" runat="server">
   Edit: <%: Model.Dinner.Title %>
</asp:Content>

<asp:Content ID="Main" ContentPlaceHolderID="MainContent" runat="server">

   <h2>Edit Dinner</h2>
   <% using (Html.BeginForm()) { %>
       <%: Html.ValidationSummary("Please correct the errors and try again.") %>
       <fieldset>
          <legend>Fields</legend>
           <div class="editor-label">
               <%: Html.LabelFor(m => m.Dinner.Title) %>
           </div>
           <div class="editor-field">
               <%: Html.TextBoxFor(m => m.Dinner.Title)%>
               <%: Html.ValidationMessageFor(m => m.Dinner.Title, "*")%>
           </div>
           <div class="editor-label">
               <%: Html.LabelFor(m => m.Dinner.EventDate) %>
           </div>
           <div class="editor-field">
               <%: Html.TextBoxFor(m => m.Dinner.EventDate)%>
               <%: Html.ValidationMessageFor(m => m.Dinner.EventDate, "*")%>
           </div>
           <div class="editor-label">
               <%: Html.LabelFor(m => m.Dinner.Description) %>
           </div>
           <div class="editor-field">
               <%: Html.TextAreaFor(m => m.Dinner.Description) %>
               <%: Html.ValidationMessageFor(m => m.Dinner.Description, "*") %>
           </div>
           <div class="editor-label">
               <%: Html.LabelFor(m => m.Dinner.Address) %>
           </div>
           <div class="editor-field">
               <%: Html.TextBoxFor(m => m.Dinner.Address) %>
               <%: Html.ValidationMessageFor(m => m.Dinner.Address, "*") %>
           </div>
<%: Html.LabelFor(m => m.Dinner.Country) %>
<%: Html.DropDownListFor(m => m.Dinner.Country, Model.Countries) %>
<%: Html.ValidationMessageFor(m => m.Dinner.Country, "*") %>
           <div class="editor-label">
               <%: Html.LabelFor(m => m.Dinner.ContactPhone)%>
           </div>
           <div class="editor-field">
               <%: Html.TextBoxFor(m => m.Dinner.ContactPhone)%>
               <%: Html.ValidationMessageFor(m => Model.Dinner.ContactPhone, "*") %>
           </div>
           <div class="editor-label">
               <%: Html.LabelFor(m => m.Dinner.Latitude)%>
           </div>
           <div class="editor-field">
               <%: Html.TextBoxFor(m => m.Dinner.Latitude)%>
               <%: Html.ValidationMessageFor(m => Model.Dinner.Latitude, "*") %>
           </div>
           <div class="editor-label">
               <%: Html.LabelFor(m => m.Dinner.Longitude)%>
           </div>
           <div class="editor-field">
               <%: Html.TextBoxFor(m => m.Dinner.Longitude)%>
               <%: Html.ValidationMessageFor(m => m.Dinner.Longitude, "*")%>
           </div>
           <p>
               <input type="submit" value="Save" />
           </p>
       </fieldset>

   <% } %>

</asp:Content>
  • 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-18T10:34:26+00:00Added an answer on May 18, 2026 at 10:34 am

    Your ‘Create’ action is going to load “Create.aspx” not “Edit.aspx”, I suspect that is still pointing to Dinner as the model.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.