Hi there,
I’ve googled till my fingers are bleeding but I just can’t find or recognise the answer I seek. I’d appreciate any help, advice, links or sample code you can provide to get me past this block…
I’ve a model from an ADO.NET Entity Data Model, Controller MVC 5 Controller with views, using Entity Framework & a view.
MODEL:
namespace iCustomerSkills.Models { using System; using System.Collections.Generic; public partial class Table_3 { public int Id { get; set; } public string A { get; set; } public string B { get; set; } public string C { get; set; } } }
CONTROLLER:
namespace iCustomerSkills.Controllers { public class ThreeController : Controller { private WTEntities3 db = new WTEntities3(); // GET: Three public async Task<ActionResult> Index() { return View(await db.Table_3.ToListAsync()); } .......
VIEW:
@model IEnumerable<iCustomerSkills.Models.Table_3> @using (Html.BeginForm()) { <div class="panel panel-default"> <div class="panel-heading">General</div> <div class="panel-body"> A: @*<input id="Chbxs" name="Chbxs" value="true" type="checkbox" onclick="this.form.submit()" />*@ @Html.CheckBox("Chbxs", new { onClick = "this.form.submit()", value = "true", Param1 = "ValueXXX" }) <br /> B: @*<input id="Chbxs" name="Chbxs" value="true" type="checkbox" onclick="this.form.submit()" />*@ @Html.CheckBox("Chbxs", new { onClick = "this.form.submit()", value = "true" }) <br /> C: @*<input id="Chbxs" name="Chbxs" value="true" type="checkbox" onclick="this.form.submit()" />*@ @Html.CheckBox("Chbxs", new { onClick = "this.form.submit()", value = "true" }) <br /> </div> </div> <p> @Html.ActionLink("Create New", "Create") </p> <table class="table"> <tr> <th> @Html.DisplayNameFor(model => model.A) </th> <th> @Html.DisplayNameFor(model => model.B) </th> <th> @Html.DisplayNameFor(model => model.C) </th> <th></th> </tr> @foreach (var item in Model) { <tr> <td> @Html.DisplayFor(modelItem => item.A) </td> <td> @Html.DisplayFor(modelItem => item.B) </td> <td> @Html.DisplayFor(modelItem => item.C) </td> </tr> } </table>
Problem:
I would like to be able to select one or more of the checkbox & use the result(s) to filter the table, so
selecting "A"
A Yes Yes Yes Yes
selecting "A" & "B"
A B
Yes Yes Yes Yes
Hi XakTacit,
Thanks for your post.
There are some references:
#using a checkboxlist to filter data
http://forums.asp.net/t/1225130.aspx?using+a+checkboxlist+to+filter+data+
#ASP.NET
MVC Display an HTML Table with Checkboxes to
Select Row Items
http://www.codeproject.com/Articles/706728/ASP-NET-MVC-Display-an-HTML-Table-with-Checkboxes
Hope this can be helpful.
Best Regards,
Eileen