Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Try to avoid using ViewBag / ViewData</strong> to pass data from your action methods to view. You must have realized now that this made your view a bit dirty. <strong>Use strongly typed view models.</strong></p> <p>Assume your view is to create something. So create a view model for that. Assuming you have multiple Actions in each stage.</p> <pre><code>public class CreateSomeThingVM { public string Title { set;get;} public List&lt;Stage&gt; Stages { set;get;} public CreateSomeThingVM() { Stages=new List&lt;Stage&gt;(); } } public class Stage { public int ID { set;get;} public string StageName { set;get;} public List&lt;Action&gt; Actions { set;get;} public Stage() { Actions =new List&lt;Action&gt;(); } } public class Action { public int ID { set;get;} public string ActionName { set;get;} } </code></pre> <p>And in your Action method, get the data and set the properties.</p> <pre><code>public ActionResult Create() { var vm=new CreateSomeThingVM(); vm.Stages=GetListOfStagesFromSomeWhereWithItsActions(); return View(vm); } </code></pre> <p>Assumuing <code>GetListOfStagesFromSomeWhereWithItsActions</code> method returns a list of <code>Stage</code> object with its proper <code>Actions</code>.(You should do your filtering here as needed to get the relevant actions for each stage).</p> <p>Now in your View which is strongly typed to our CreateSomeThingVM view model, write some clean code</p> <pre><code>@model CreateSomeThingVM @foreach(var stage in Model.Stages) { &lt;h2&gt;@stage.StageName&lt;/h2&gt; foreach(var action in Model.Actions) { &lt;p&gt;@action.ActionName&lt;/p&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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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