using System.Collections.Generic;
namespace HelloWorldMvcApp
public class HomeController : Controller
public ActionResult Index()
var nameList = new List<NameList>() {
new NameList() { personId = 101, personFullname = "John Smith" },
new NameList() { personId = 191, personFullname = "Jim Smith" },
new NameList() { personId = 202, personFullname = "John Doe" },
var getddlName = (from a in nameList
select new SelectListItem
Value = a.personId.ToString(),
ViewBag.ddlNameList = getddlName;
var ddlPersonIds = "101,191,202";
if (ddlPersonIds != null)
List<string> list1 = new List<string>();
var empIds = ddlPersonIds.Split(',');
foreach(var c in empIds){
ViewBag.ddlPersonName = list1;
return View(new SampleViewModel());