Guest User

Untitled

a guest
Dec 10th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. public ActionResult Index(string FilialType)
  2. {
  3. var FilialQry = from d in db.Probs
  4. orderby d.DEP.dep_name
  5. select d.DEP.dep_name;
  6. var FilialLst = new List<string>();
  7.  
  8. FilialLst.AddRange(FilialQry.Distinct());
  9. ViewBag.FilialType= new SelectList(FilialLst);
  10.  
  11. var probs = from s in db.Probs
  12. select s;
  13.  
  14. if (!string.IsNullOrEmpty(FilialType))
  15. {
  16. probs= probs.Where(x => x.DEP.dep_name == FilialType);
  17. }
  18.  
  19. return View(probs);
  20. }
  21.  
  22. @using (Html.BeginForm("Index", "Probs", FormMethod.Get))
  23. {
  24. <p>
  25. Выберите из списка: @Html.DropDownList("FilialType", String.Empty) <!-- вместо String.Empty также было значение "All" -->
  26. <input type="submit" value="Поиск" />
  27. </p>
  28. }
Add Comment
Please, Sign In to add comment