Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I believe the reason you're not getting the correct values is because you're using <code>Html.TextAreaFor</code> the wrong way. The x in your code points to your <code>Page.Model</code> attribute while your val is not related to that attribute in a way that ASP.NET MVC2 can understand.</p> <p>You could change your code to look something like this:</p> <pre><code>&lt;%using (Html.BeginForm("MeetingTodo", "OA", FormMethod.Post, new { id = "TaskForm" })) {%&gt;&lt;%=Html.Hidden("id",ViewContext.RouteData.Values["id"]) %&gt; &lt;div class="container"&gt; var ix = 0; &lt;%foreach (var val in Model.Distinct()) { %&gt; &lt;div class="grdrow" &gt; &lt;div class="grdrightcaption" style="width:173px;" &gt;&lt;%=val.setupEmployee.EmployeeName%&gt;&lt;/div&gt; &lt;div class="grdcells" &gt;&lt;%=Html.TextArea(String.Format("employee[{0}].Todo", ix), val.Todo, new { maxlength = 200, style="width:300px;" })%&gt; &lt;%=Html.Hidden(String.Format("employee[{0}].EmployeeID", ix), val.EmployeeID)%&gt; &lt;/div&gt; &lt;div class="grdcells" style="width:50px;" &gt; &lt;%=Html.CheckBox(String.Format("employee[{0}].Required", ix), val.Required)%&gt; &lt;/div&gt; &lt;/div&gt; &lt;% ++ix }%&gt; &lt;/div&gt; &lt;br /&gt; &lt;button type="submit" class="button"&gt;save&lt;/button&gt; &lt;%}%&gt; </code></pre> <p>And then in your action declaration decorate your parameters as following:</p> <pre><code>public ActionResult MeetingTodo([Bind(Prefix = "employee")]Employee[] employees) </code></pre> <p>A better and cleaner way would be to do this though.</p> <pre><code>&lt;% for (int i = 0; i &lt; Model.Count(); ++i) { %&gt; &lt;%= Html.HiddenFor(m =&gt; m[i].SomeAttribute) %&gt; &lt;div&gt;&lt;%= Html.TextAreaFor(m =&gt; m[i].SomeTextAttribute) %&gt;&lt;/div&gt; &lt;% } %&gt; </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. 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