-1

~/Views/PlanBuilder/PlanBuilder.cshtml

@{
ViewBag.Title = "PlanBuilder";
Layout = "~/Views/Shared/_LayoutPlanBuilder.cshtml";
}

<div id="tabs-1">

<div id="wrap" class="left">
<ul>
@Html.Partial("~/Views/Hall/Index.cshtml");
</ul>
</div>

</div>

~/Views/Hall/Index.cshtml

@model IEnumerable<ShaadiPlanner.Models.Hall>

@{
     ViewBag.Title = "Index";
     Layout = "~/Views/Shared/_LayoutPlanBuilder.cshtml";
    }

@foreach (var item in Model)  <!-- ERROR LINE -->
{
     <li id="@Html.DisplayFor(modelItem => item.ID)" class="options left">
          <div class="box-header">
               <h4 class="left"><span class="name">@Html.DisplayFor(modelItem => item.Name)</span> (@Html.DisplayFor(modelItem => item.Area))</h4>
               <h4 class="right">Rs. <span class="price">@Html.DisplayFor(modelItem => item.EstCost)</span></h4>
          </div>
     </li>
}

Object reference not set to an instance of an object.

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 the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Note: When i define Model in the @Html.Partial code like this then @Html.Partial("~/Views/Hall/Index.cshtml", model); it give following error.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0103: The name 'model' does not exist in the current context

  • 1
    You should try to make this question a bit more specific and targeted rather than just dumping error details and having no actual question. – Boeckm Nov 01 '12 at 11:30

1 Answers1

1

Try uppercasing Model, i.e.

@Html.Partial("~/Views/Hall/Index.cshtml", Model);

As @webdeveloper comments, you have not got a model declared in your view!

dove
  • 20,469
  • 14
  • 82
  • 108