I have an ASP.NET MVC application that uses a single view to display the properties and child elements (with their properties) of a model object.
My model looks something like this:
public class Market { public int ID { get; set; } public string Name { get; set; } public string Description { get; set; } public IList<EmailAddress> EmailAddresses { get; set; } } public class EmailAddress { public virtual int ID { get; set; } public virtual int MarketID { get; set; } public virtual string Email { get; set; } }
In the view, I want to use a table to display a list of related email addresses. For this I use Html.Grid.
<%= Html.Grid(Model.EmailAddresses).Columns( column => { column.For(x => x.Email + Html.Hidden("ID", x.ID)).Encode(false).Sortable(false); }) .Attributes(style => "width:100%") .Attributes(id => "emailGrid") .Empty("There are no Email Addresses set up") %>
However, when I do this, the hidden identifier is the identifier of the parent Market object, not the EmailAddress address.
How can i fix this?
source share