In general, when we are getting comma separated value from database, we need to split and loop to select multiple items from the ListBox.
var employeeIds = '@ViewBag.EmployeeIds'; // comma separated value
var array = employeeIds.split(',');
for (var i = 0; i < array.length; i++) {
if (array[i].length > 0) {
$('#EmployeeIds option[value=' + array[i] + ']').attr("selected", true);
}
}
Here we are assuming that ViewBag.EmployeeIds have comma separated value, #EmployeeIds is the id of the listbox.