SearchItemSelect.cs 1.0 KB

123456789101112131415161718192021222324252627282930
  1. using System.Collections.Generic;
  2. using System.Web.Mvc;
  3. namespace WeOnlineApp.Views.Shared.SearchForm
  4. {
  5. public class SearchItemSelect
  6. {
  7. public SearchItemSelect(string filed, List<SelectListItem> items, bool isAddBlank)
  8. {
  9. Filed = filed;
  10. Items = items;
  11. IsAddBlank = isAddBlank;
  12. ItemStrs = IsAddBlank ? "<option value=\'\' selected>请选择</option>" : "";
  13. foreach (var item in Items)
  14. {
  15. ItemStrs += $"<option value=\'{item.Value}\'>{item.Text}</option>";
  16. }
  17. }
  18. public SearchItemSelect(string filed, string itemStr, bool isAddBlank)
  19. {
  20. Filed = filed;
  21. IsAddBlank = isAddBlank;
  22. ItemStrs = (isAddBlank ? "<option value=\'\' selected>请选择</option>" : "") + itemStr;
  23. }
  24. public string Filed { get; set; }
  25. public bool IsAddBlank { get; set; }
  26. public List<SelectListItem> Items { get; set; }
  27. public string ItemStrs { get; }
  28. }
  29. }