将 Monorail RadioFields 绑定到 GenericLists

发布于 2024-08-04 03:25:28 字数 381 浏览 1 评论 0原文

在我看来,我有以下对象绑定到表单:

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

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

我将此信息作为各种 RadioField 组呈现给用户。

如何绑定 RadioFields,以便它们为 Items 中的每个项目显示一组 RadioFields。每组 RadioFields 对每条线都有一个选项,并且每组 RadioFields 都受分辨率限制?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紧拥背影 2024-08-11 03:25:28

这是一个简单的旧 HTML 问题

<% 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>
<% } %>

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>
<% } %>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文