문제

I have the following object which I bind to a Form in my view:

public class Foo
{  
    public List<Bar> Items { get; set; }
}

public class Bar
{
    public List<string> Lines { get; set; }
    public int Resolution { get; set; }
}

I am presenting this information to the user as various groups of RadioFields.

How do I bind the RadioFields so that they display a group of RadioFields for each item in Items. Each group of RadioFields having an option for each Lines and that each group of RadioFields is bounded to Resolution?

도움이 되었습니까?

해결책

It's a plain old HTML question

<% foreach (var bar in view.Foo.Items) { %>
   <% var barIx = 0; %>
<fieldset>
   <% foreach (var line in bar.Lines) { %>
     <% var lineIx = 0; %>
   <label for="bar<%=barIx%>_line_<%=lineIx%>"><%=line%>: </label>
   <input type="radio" value="<%=line%>" name="bar[<%=barIx%>].Lines" id="bar<%=barIx%>_line_<%=lineIx%>" />
     <% ++lineIx; %>
   <% } %>
   <label for="bar<%=barIx%>_resolution">Resolution: </label>
   <input type="text" value="<%=bar.Resolution%>" name="bar[<%=barIx%>].Resolution" id="bar<%=barIx%>_resolution" />
   <% ++barIx; %>
</fieldset>
<% } %>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top