Multiple checkboxes in razor (using foreach)

You cannot use a foreach loop to generate controls for a collection. The html you’re generating for each checkbox (and for the associated hidden input) is <input type=”checkbox” name=”item.ToExport” …/>. Your model does not contain a property which is named item. Use a for loop @for(int i = 0; i < Model.ExportingGroups.Count; i++) { <tr> … Read more

Custom Checkbox

There is a CSS trick that actually works by hiding the checkbox (or radio), defining a label (which in all relevant browsers will turn the checkbox on/off) that will be the visual representation, and using the :checked and + selectors. This is just a simple example: .foscheck input { display: none; } .foscheck label { … Read more

Maintain state of a dynamic list of checkboxes in ASP.NET MVC

I got it working after much playing around with the various different approaches. In the view: <%string[] PostFeatures = Request.Form.GetValues(“Features”);%> <% foreach (var Feature in (ViewData[“AllPropertyFeatures”] as IEnumerable<MySolution.Models.PropertyFeature>)) { %> <input type=”checkbox” name=”Features” id=”Feature<%=Feature.PropertyFeatureID.ToString()%>” value=”<%=Feature.PropertyFeatureID%>” <%if(PostFeatures!=null) { if(PostFeatures.Contains(Feature.PropertyFeatureID.ToString())) { Response.Write(“checked=\”checked\””); } } %> /> <label for=”Feature<%=Feature.PropertyFeatureID%>”> <%=Feature.Description%></label> <% } %> In the receiving controller method: … Read more

Filter Array Using Checkboxes with AngularJS

EDIT 2 Per all the requests of the OP, here is the final state. http://jsfiddle.net/rzgWr/19/ EDIT (OP added a bounty) Per your bounty, is this what you wanted? http://jsfiddle.net/rzgWr/17/ Is this what you wanted? http://jsfiddle.net/rzgWr/12/ Template <div ng-controller=”MyCtrl”> <div> <div> Search: <input name=”company” type=”text” class=”search-input” ng-model=”query”/> </div> <div ng-init=”pantsGroup = (players | groupBy:’pants’)”> <div ng-repeat=”pants … Read more