Mark Tabor

Mark Tabor

  • 575
  • 1.9k
  • 431.3k

applying _Layout view to in mvc

Apr 27 2019 5:13 AM
Hi I have a _layout View which is basically having a model call as shown below
@model Pakeeza_Estate.Models.Country
Now i have created a new Index view and i want to use this above layout as my layout , my index view itself is having an model class as
@model Pakeeza_Estate.Models.Property
now when i set the layout property to
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
and i run the project it gives error
There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'CountryId'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in
i knew it is asking to give the model of country as well , but i already have another model with this view so how i can add two models to the same view , other then Viewmodel apporoach can i pass the model in controller method instead of binding it using view

Answers (5)