asp.net - C# asp.net 动态填充
问题描述
解决方案
问题是:
CountryList = new SelectListItem[]
{
new SelectListItem(countriesList[i], countriesList[i])
};
每次您使用一个元素创建一个新的项目列表时。您应该将所有项目添加到一个列表中。像这样的东西:
public async Task<IActionResult> OnGetAsync(string email)
{
List<string> countriesList = GetCountriesList.GetCountries();
Debug.WriteLine("************** countriesListReturned: " + countriesList.ToString());
CountryList = countriesList.Select(x => new SelectListItem(x, x));
[normal other code to populate the view goes here]
return Page();
}
推荐阅读
- php - 想要从 CSV 文件中获取在 php 的其他列中具有相同值的 ID
- matlab - 在 MATLAB 中验证大数定律
- c++ - 为什么在 pop_back() 操作之后它仍然打印完整的向量?
- python - 仅当数据框中的缺失值介于两个相同值之间时才填充缺失值
- database - 如何将 MariaDB 迁移到 Aurora
- node.js - 如何获取由 Node.js 中的 firebase 实时数据库填充的下拉(组合框)值?
- python - 如何使用自定义函数作为 Django autocomplete_fields
- java - 无法从 javax.ws.rs.client.WebTarget 找到内容类型 */* 的 MessageBodyReader
- powerbi - 计算列中的第二大值
- r - 在 R 中集成函数与 truncdist 的“奇怪”行为