In my asp.MVC application I have created two combo boxes as Manager and TopManager. I have loaded Manager list to the Temp list and another Temp list to the Top managers list.
@using Asp_PASMVC.Infrastructure
@{
List Employees = (List)TempData.Peek("EmployeeList");
List TopEmp = (List)TempData.Peek("TopEmpDroDown");
if (Employees.Exists(x => x.Value == "1"))
{
Employees.Where(x => x.Value == "1").First().Selected = true;
}
if (TopEmp.Exists(x=> x.Value =="1"))
{
TopEmp.Where(x => x.Value == "1").First().Selected = true;
}
string UserLvel = TempData.Peek("UserLevelClaims").ToString();
}
Here is the View
@using (Html.BeginCollectionItem("ApprovalPartyList"))
{
For Manager
@Html.RadioButtonFor(m => m.Approve_Type, false)
@if (UserLvel != "1")
{
For Top Manager
@Html.RadioButtonFor(m => m.Approve_Type, true)
}
Select the Approver
@Html.DropDownListFor(model => model.Approver_Id, Employees, new { @class = "js-dropdown" })
@Html.ValidationMessageFor(model => model.Approver_Id, "", new { @class = "text-danger" })
}
The issue is combo box only shows the Manager list ( I have assigned ) , I want it to change If Radio button ` Manager ` selected the combo box should load the 'Employees' and If 'Top Manager' Selected, Should load the 'TopEmp' list to the combo box. I think this shold be done with javascript. But no idea of creating that. Can you help me on this ? Thanks in advance.
Sachin SinghPosted Sep 15, 2021, 6:20 AM