forum

Home / DeveloperSection / Forums / Access to a variable from a view in another view

Access to a variable from a view in another view

Anonymous User 1776 23-Dec-2013

I have the following problem with applpication:

Index.cshtml:

@model IEnumerable<ForestryManagement.Models.Forestry>
 @foreach (var forestry in Model)
    {
        <li>@Html.ActionLink(forestry.Name, "Index12", new {tree = forestry.ForestryID})
    }

When you click on one Forestry (ActionLink), you will be redirected to the Index12, where the trees from these Forestry are listed

Index12.cshtml:

@model IEnumerable<ForestryManagement.Models.Tree>
@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.treeName)
        </td>
        </tr>
@Html.ActionLink("Create new Tree", "Create", new { id = **??????**})

Now, when i will create another tree in this forestry, i need the ID from the forestry on my Index12.cshtml page for the ActioLink


Updated on 23-Dec-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By