Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Based on the names <code>numerators</code> and <code>denominators</code> it looks like you have implemented the lists as fields on the model.</p> <p>You should <a href="https://stackoverflow.com/a/7789986/700926">use properties instead</a> for the model binding to work properly (which I assume that @Raphael has done).</p> <p>A working model would look like this:</p> <pre><code>public class BetChargeModel { public List&lt;double&gt; numerators { get; set; } public List&lt;double&gt; denominators { get; set; } } </code></pre> <p>... and to follow to naming conventions, make sure to rename <code>numerators</code> to <code>Numerators</code> and <code>denominators</code> to <code>Denominators</code>.</p> <p>However, if this does not resolve your model binding issue, please elaborate and post your model implementation :)</p> <p>-- UPDATE</p> <p>As you have reported that the issue still persists I will post the code I have implemented based on your own provided samples - then you can cross check to make sure everything looks right on your machine - the code shown in the following is tested and works:</p> <p><strong><em>Model:</em></strong></p> <pre><code>public class BetChargeModel { public List&lt;double&gt; numerators { get; set; } public List&lt;double&gt; denominators { get; set; } } </code></pre> <p><strong><em>View:</em></strong></p> <pre><code>@model Project.Models.BetChargeModel @using (Html.BeginForm()) { &lt;div&gt; @Html.TextBoxFor(m=&gt;m.numerators[0]) / @Html.TextBoxFor(m=&gt;m.denominators[0]) &lt;/div&gt; &lt;div&gt; @Html.TextBoxFor(m =&gt; m.numerators[1]) / @Html.TextBoxFor(m =&gt; m.denominators[1]) &lt;/div&gt; &lt;div&gt; &lt;input type="submit" value="Calculate" /&gt; &lt;/div&gt; } </code></pre> <p><strong><em>Controller:</em></strong></p> <pre><code>public ActionResult Index() { var model = new BetChargeModel { numerators = new List&lt;double&gt; {0, 0}, denominators = new List&lt;double&gt; {1, 1} }; return View(model); } [HttpPost] public ActionResult Index(BetChargeModel model) { var odds1 = model.numerators[0] / model.denominators[0]; var odds = model.numerators[1] / model.denominators[1]; return null; } </code></pre>
    singulars
    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. 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.
 

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