[HttpPost]
public ActionResult Index(DropDownListModel model, string[] DropData)
{
ViewBag.datasource1 = data;
DropDownListProperties ddl = new DropDownListProperties();
ddl.DataSource = DropData;
ddl.Value = string.Join(",", DropData);
DropDownListFields ddf = new DropDownListFields();
ddf.Text = "Description";
//ddf.Value = "id"; <-- leads to duplicated selected values
ddf.Value = "Description";
ddf.Id = "id";
ddf.Selected = "Checked";
ddl.DropDownListFields = ddf;
ViewData["ddl"] = ddl;
return View(model);
} |