I need to insert a default value at the top of the result I have as below….
Can someone give me a clue how to do it with an anonymous type?
public JsonResult GetThingsForStuff(string stuff)
{
var things= from c in db.MYTABLE
where c.idofstuff == stuff
select new { id = c.realid, name = c.realname};
return Json(things, JsonRequestBehavior.AllowGet);
}
In my controller I do this initially by
List<SelectListItem> items3 = new SelectList(db.MYTABLE.ToList().Distinct(), "realid", "realname").ToList();
items3.Insert(0, (new SelectListItem { Text = "Select Me", Value = "0" }));
ViewBag.Things = items3;
by I have a javascript function reloading this dropdownlist based on the selected “stuff” and I need this default back at the top.
Any help would be greatly appreciated.
Thanks,
David
You could concatenate them: