I have a ViewBag.People made up from a View;
var query = db.Vw_INTERACTPEOPLE.Select(p => new { p.PersonID, p.Fullname });
ViewBag.People = new SelectList(query.AsEnumerable(), "PersonID", "FullName");
Which all works fine, but in my view I have another model populating a table, and one of the items is populates is an JobcontactID (textbox) which links to the PersonID (i didnt design the database). So I want to search the viewbag for the ID and rather than displaying it I want to display the persons Fullname, so is there any viewbag search functionality?
ViewBagis just adynamicwrapper aroundViewData(which allows the property invoked at runtime to become the key which will be used to look up the value inViewData). You can queryViewDatalike this:Update So you wish to query the select list itself?
Here’s a function defined in the razor view: