Note that there are some explanatory texts on larger screens.

plurals
  1. PORazor CheckboxFor and RadioButtonFor in a nested loop
    primarykey
    data
    text
    <p>Here is my model</p> <pre><code>public class Settings { public string Label { get; set; } public bool Display { get; set; } //controls checkbox public bool Default { get; set; } //controls radiobutton public int GroupId { get; set; } } </code></pre> <p>Here is my controller</p> <pre><code>public ActionResult LaunchSettings(int portletInstanceId) { List&lt;List&lt;Settings&gt;&gt; listOfGroups; return PartialView("Settings", listOfGroups); } </code></pre> <p>Here is my view</p> <pre><code> @foreach (List&lt;Settings&gt; group in Model) { foreach(Settings settings in group) { &lt;ol&gt; &lt;li&gt; *****ADD CHECKBOX FOR EACH ITEM IN THE LIST***** &lt;/li&gt; &lt;li&gt; @Html.DisplayFor(m =&gt; settings.Label) &lt;/li&gt; &lt;li&gt; *****ADD SET OF RADIO BUTTONS HERE PER GROUP***** &lt;/li&gt; &lt;/ol&gt; } } </code></pre> <p>The inner list contains settings that are grouped based on the group id of the data. The outer list of a list of the inner list.</p> <p>How do I achieve each of the tasks described in my view above between the "<strong>*</strong>" tags? I searched on google and couldn't find an appropriate answer. If I missed something, please understand that it's not due to lack of searching.</p> <p>EDIT Here is the xml that drives the model</p> <pre><code> &lt;state&gt; &lt;searchoptions&gt; &lt;searchoption name="Option1" label="Option A" display="true" default="true" group="1"/&gt; &lt;searchoption name="Option2" label="Option B" display="true" default="false" group="1"/&gt; &lt;searchoption name="Option3" label="Option C" display="false" default="false" group="1"/&gt; &lt;searchoption name="Option4" label="Option D" display="false" group="2"/&gt; &lt;searchoption name="Option5" label="Option E" display="false" group="3"/&gt; &lt;/searchoptions&gt; &lt;/state&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload