Hii to all,
I have a requirement that i need to place two dropdown lists.In First Dropdown i need to display Employee Ids from database,when user selects any Id,the respective EmployeeIds Name should display in another second dropdown.I have done this succesfully, but here what my actuall requirement is i need to show my first dropdown with Checkboxes i.e for each EmployeeId i need to show one Checkbox to the left of the Id,then user can select multiple ids in the same order i need to show checked ids Names in Second Dropdown, i have tried by googling and downloaded dropdownchecklist plugin,but i was unable to reach my requirement.Iam using MVC3 Razor.
Here is my View Code:-
<fieldset>
EmployeeIds<br />
@Html.DropDownListFor(m => m.selectedEmpid, new SelectList(Model.getAlldeptNos), "Select Empid", new { id = "getSelectedId" })
@Html.DropDownListFor(m => m.selectedEmpid, new SelectList(Model.getEname), new { id = "displayEname" })<br />
</fieldset>
<script type="text/javascript">
$(function () {
$('#getSelectedId').change(function () {
var selectedEmpIdValue = $(this).val();
alert(selectedEmpIdValue);
$.ajax({
url: '@Url.Action("Index", "Home")',
type: 'POST',
data: { empid: selectedEmpIdValue },
success: function (data) {
alert(data);
$('#displayEname').empty();
for (var i = 0; i < data.length; i++) {
$('#displayEname').append('<option value=' + i + '>'
+ data +
'</option>');
}
}
});
});
});
Here is My Controllers Code:-
PersonAccountInfoViewModel model = new PersonAccountInfoViewModel();
using (personalEntities db = new personalEntities())
{
model.getEname = new List<string>();
model.getobj = new List<empdetail>();
var emply = (from p in db.empdetails
select p);
var getEmpid = (from s in db.empdetails select s.empid);
model.getobj = emply.ToList();
model.getAlldeptNos = getEmpid.ToList();
}
var selectedDropdownId = (from d in model.getobj where d.empid == empid select d.ename);
model.getEname = selectedDropdownId.ToList();
return new JsonResult { Data = model.getEname };
}
Please any one can help me how to work with dropdownchecklist plugin or guide me is there any alternative to reach my requirement.Thanks in advance
Thanks
Ramu</empdetail></string>