Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC 3 Processing a table row depending on whether a check box is checked
    primarykey
    data
    text
    <p>Hi I am very new to MVC and I am currently trying to implement a small human resources system using MVC 3 and Entity Framework 4.1. Right now I am stuck on what seems like a very trivial task of displaying a table which lists employees who have recently taken sick leave off from work and on each table row I have a checkbox which users will check if the the employee has provided a sick sheet. I also want to have a button/Link/etc on each row which when clicked would invoke a call to a controller method and somehow pass the checked value of the check box together with the id of the sick leave application. I tried using an actionlink but I'm kind of stumped at what I would enter in as the routevalue meant for the checked value of the checkbox. This same functionality would take me only minutes to do in web forms but like I said I'm new to MVC and since this seems like a pretty simple task there is probably a pretty simple solution somewhere out there but I just can't figure it out for the life of me. If anything I'm guessing this might need a bit of jquery (which btw still looks like a foreign language to me sometimes) and hidden fields? Arrgghhh I don't know. Could someone please help me?? Thanks in advance.</p> <p>Here is my View:</p> <pre><code> @model IEnumerable&lt;LeaveSoft.Models.PendingSickLeave&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt; Applicant's Name &lt;/th&gt; &lt;th&gt; Leave Start &lt;/th&gt; &lt;th&gt; Leave End &lt;/th&gt; &lt;th&gt; Number Of Days &lt;/th&gt; &lt;th&gt; Reason &lt;/th&gt; &lt;th&gt; Confirm &lt;/th&gt; &lt;th&gt; &lt;/th&gt; &lt;/tr&gt; @foreach (var item in Model) { &lt;tr&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.UserFullName) &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.StartDate) &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.EndDate) &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.NumOfDays) &lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.LeaveReason) &lt;/td&gt; &lt;td&gt; @Html.CheckBox("chkConfirm") @Html.Label("", "Sick Sheet Provided") &lt;/td&gt; &lt;td&gt; @Html.ActionLink("Process", "ProcessSickLeave", new { id = item.ApplicationID, sicksheet = "THIS IS THE PART I DON'T KNOW" }) &lt;/td&gt; &lt;/tr&gt; } &lt;/table&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