ID | Name |
1 | A |
2 | B |
3 | C |
Id | ParentId | Name |
1 | 1 | Test1 |
2 | 2 | Test2 |
3 | 6 | Test3 |
4 | 7 | Test4 |
<div class="frame">
<div class="row">
<div class="col-xs-8 col-sm-4">
<span class="txt">Select Group</span>
@Html.EJ().DropDownList("parent").Datasource((IEnumerable<Parents>)ViewBag.datasource).CssClass("flat-saffron").DropDownListFields(df => df.ID("ID").Text("Name").Value("ParentId")).WatermarkText("Select Parent").Width("100%").CascadeTo("child")
</div>
<div class="col-xs-8 col-sm-4">
<span class="txt">Select Country</span>
@Html.EJ().DropDownList("child").Datasource((IEnumerable<JobImpositions>)ViewBag.datasource1).CssClass("flat-saffron").DropDownListFields(df => df.ID("ParentId").Text("Name").Value("ParentId")).WatermarkText("Select Child").Width("100%").Enabled(false)
</div>
</div>
</div> |
public partial class DropdownlistController : Controller
{
List<Parents> parent = new List<Parents>();
List<JobImpositions> test = new List<JobImpositions>();
public ActionResult DropdownlistFeatures()
{
parent.Add(new Parents { ParentId = "1", Name = "A" });
parent.Add(new Parents { ParentId = "2", Name = "B" });
parent.Add(new Parents { ParentId = "3", Name = "c" });
ViewBag.datasource = parent;
test.Add(new JobImpositions { Name = "Text1", ID = "1", ParentId = "1" });
test.Add(new JobImpositions { Name = "Text2", ID = "2", ParentId = "1" });
test.Add(new JobImpositions { Name = "Text3", ID = "3", ParentId = "2" });
test.Add(new JobImpositions { Name = "Text4", ID = "4", ParentId = "3" });
ViewBag.datasource1 = test;
return View();
}
}
public class Parents
{
public string ParentId { get; set; }
public string Name { get; set; }
}
public class JobImpositions
{
public string Name { get; set; }
public string ID { get; set; }
public string ParentId { get; set; }
} |
Parent | Child | |||
Id | Name | EmpId | Department | |
1 | Test | 1 | Accounts | |
2 | Test2 | 2 | Sales | |
3 | Test3 | 5 | Operations |