如何解决如何通过在Razor页面中输入的字母过滤@ Html.DropDownListFor?
这是我Controller.cs中的功能
public IActionResult Create()
{
//Create Nation List
var region = CultureInfo.GetCultures(CultureTypes.SpecificCultures)
.Select(x => new RegionInfo(x.LCID));
Regex regex = new Regex(@"^[A-Z]+$");
List<Tuple<string,string>> countryList = (from x in region
select new Tuple<string,string>(x.ThreeLetterISORegionName,x.DisplayName))
.Distinct()
.OrderBy(x => x.Item2)
.Where(x => regex.IsMatch(x.Item1))
.ToList<Tuple<string,string>>();
List<string> xxxCountryList = countryList
.Select(x => new string(x.Item2 + " (" + x.Item1 + ")")).ToList();
ViewBag.CountryTupleList = xxxCountryList;
return View();
}
这是我认为的代码。
<div class="form-group col-lg-8 col-md-8 col-xs-12">
<div class="ml-1">
@{
@Html.DropDownListFor(m => m.Nationality,new SelectList(ViewBag.CountryTupleList),"- Please Select -",new { @class = "form-control" })
}
</div>
</div>
当前国家/地区正在显示在下拉列表中。一直向下滚动有点繁琐。谁能建议我如何过滤计数器?即输入字母“ G”,仅显示以字母G开头的国家/地区!提前谢谢!
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。