Alright, I'm trying to pass a Dictionary, where key = int, and value = Prototype into my view.
Prototype:
public class Prototype
{
public string Value { get; set; }
public string PropertyName { get; set; }
public Options Type { get; set; }
}
After the Dictionary has been passed into my view I'm doing a foreach loop to render each of the KeyValuePair:
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Dictionary<System.Int32,MvcApplication1.Models.Prototype>>" %>
<%@ Import Namespace="SecuredFormExample.Code" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Index</title>
</head>
<body>
<div>
<% Html.BeginForm("Save", "Products", FormMethod.Post); %>
<% foreach (KeyValuePair<int, Prototype> p in Model)
{ %>
<%: Html.Label(p.Value.PropertyName) %>
<%: Html.TextBox("Value") %>
<% } %>
<p><input type="submit" value="submit" /></p>
<% Html.EndForm(); %>
</div>
</body>
</html>
Now is the question, is it possible to pass the other values in the KeyValuePair value part back to the action aswell, or do I need to throw them all into hidden fields?