- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
public JsonResult Autocomplete(string term)
{
var result = new List<KeyValuePair<string, string>>();
IList<SelectListItem> List = new List<SelectListItem>();
List.Add(new SelectListItem { Text = "test1", Value = "0" });
List.Add(new SelectListItem { Text = "test2", Value = "1" });
List.Add(new SelectListItem { Text = "test3", Value = "2" });
List.Add(new SelectListItem { Text = "test4", Value = "3" });
foreach (var item in List)
{
result.Add(new KeyValuePair<string, string>(item.Value.ToString(), item.Text));
}
var result3 = result.Where(s => s.Value.ToLower().Contains(term.ToLower())).Select(w => w).ToList();
return Json(result3, JsonRequestBehavior.AllowGet);
}