
In above image P means Parent and C means child and 1 attached to computer indicated computer is child of Electronics likewise MySql is child of Computer programming.
I want to send multiple selected checkbox value with ajax to my controller and filter data based on selected checked value.
This is my model:
public class sample
{
public int Id { get; set; }
public string parent { get; set; }
public virtual ICollection<childsample> childsamples { get; set; }
}
public class childsample
{
public int childid { get; set; }
public string child { get; set; }
}
My view(.cshhtml):
@foreach (var sample in Model.sample)
{
<label class="Parentlabel">
<input type="checkbox" name="parentHeader" class="ParentHeader Right5" />
@sample.parent
</label>
<div class="bgContainer">
@foreach (var child in @sample.childsamples)
{
<label class="childLabel">
<input class="ChildHeader Right5" type="checkbox" name="childHeader" value="@child.child" />@child.child
</label>
}
</div>
}
My controller:
Public ActionResult filterData(int [] checkedIds) // if id is passed as paramter from ajax
Can anybody tell me how do i send this multiple checked checkbox value to my controller with ajax and filter data based on checked checkbox value?