I have a collection of Shelves and each shelf has a collection of products. To optimize reuse I have created a partial view ProductList.ascx that is called as I loop through the list of Shelves. In the partial view I want to have an Add link for each type of product, and need the Shelf Id to do so. Since the partial view is a collection of products and may have no products on that shelf yet, how would I include an add link to the partial that includes the Shelf Id?
Parent View:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<ShelfDetail>>" %>
<% foreach (ShelfDetail shelf in Model)
{ %>
<%= Html.Encode(shelf.Name) %>
<%= Html.ActionLink("Delete Shelf", "Delete", "Shelf", new { Id = shelf.Id }, null)%>
<%= Html.ActionLink("Edit Shelf", "Edit", "Shelf", new { Id = shelf.Id }, null) %>
<% Html.RenderPartial("SoupList", shelf.Soups); %>
<% Html.RenderPartial("PieList", shelf.Pies); %>
<p><%= Html.Encode(shelf.Description) %></p>
<% } %>
<% } %>
Child Soup View (trying to add the route value where it says "NEED SHELF ID HERE"):
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<SoupList>>" %>
Doors: <%= Html.ActionLink("Add Soup", "Add", "Soup", NEED SHELF ID HERE, null)%>
<% foreach (SoupList soup in Model)
{ %>
<%= Html.Encode(soup.Flavor) %>
<% } %>