Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:-

SQL
<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">
XML
$(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>
Posted

1 solution

Start here: http://bit.ly/19sCQtg[^]

But this one looks the easiest: http://code.google.com/p/dropdown-check-list/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900