DineshChauhan
DineshChauhan

Reputation: 121

The name 'model' does not exist in the current context MVC 4 Razor

I am new to MVC4 so i dont know why i am getting this error " The name 'model' does not exist in the current context" please help

         @foreach (var item in model)
         {
         <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Title)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Address)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Mobile)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.City)
        </td>
         <td>
            @Html.DisplayFor(modelItem => item.State)
        </td>
        <td>
            <a href="#" id="[email protected]"  onclick="OpenDialog('/Company/[email protected]',600,800);" > Edit </a>|
            <a href="#" id="[email protected]"  onclick="DeleteCompany(@item.ID)" > Delete </a>
        </td>
    </tr>
}

Upvotes: 1

Views: 1467

Answers (1)

Kartikeya Khosla
Kartikeya Khosla

Reputation: 18873

Instead of model it should be Model in foreach loop as :--

@foreach (var item in Model){ ..... }

Upvotes: 2

Related Questions