Note that there are some explanatory texts on larger screens.

plurals
  1. POmvc3 checkbox value after submit
    primarykey
    data
    text
    <p>I have a form with 2 fields a dropdownlist and a checkbox. I have everything working correctly but i can not for some reason obtain the value of a checkbox if it is checked this is my code..</p> <pre><code>[HttpPost] public ActionResult view(string pick) { switch (pick) { case "Deny": // capture checkbox value here break; case "Accept": // capture checkbox value here break; } return View(); } </code></pre> <p>This is my view</p> <pre><code>@using (Html.BeginForm("view", "grouprequest", FormMethod.Post, new {})) { @Html.DropDownList("pick", new SelectList(new List&lt;Object&gt;{ new{ Text ="Accept", Value= "Accept"},new{ Text ="Deny", Value= "Deny"}}, "Value", "Text"), new {}) &lt;input type="submit" name="work" id="work" value="Update" style="font-size:16px" /&gt; foreach (var item in Model) { &lt;input type="checkbox" id="@item.grouprequestID" name="@item.grouprequestID" value="@item.grouprequestID" /&gt; } } </code></pre> <p>Basically the dropdownlist has 2 options which are <strong>Accept</strong> and <strong>Deny</strong> I can capture which one the user chooses via the <strong>SWITCH-case</strong> in the controller now how can I capture the value of the checkboxes? If you notice the Checkboxes have a variable to them named <strong>@groupRequestID</strong> so every checkbox has a different unique value like 1,2,3 etc.. any help would be greatly appreciated !!</p> <p>The Model</p> <pre><code> public class grouprequest { [Key] public int grouprequestID { get; set; } public int? profileID { get; set; } public int? registrationID { get; set; } public DateTime expires { get; set; } public int? Grouplink { get; set; } } </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.
 

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