【发布时间】:2022-01-12 17:42:44
【问题描述】:
This is the image of database I'm working with
我想显示“单词”,但只使用“id”。如果我有 id “11111”,我需要显示单词“abascus”
这是我到目前为止所做的:
//This is the code behind file (.cshtml.cs)
public IList<testdiceware> testdiceware { get; set; }
public async Task OnGetAsync()
{
testdiceware = await _db.testdiceware.ToListAsync();
}
这就是我试图显示信息的方式
//This is the .cshtml where I'd like to display the result
@Html.DisplayFor(model => model.testdiceware[11111].word);
这给了我 ArgumentOutOfBounds 异常可能是因为它引用了这个value (marked in red),但我想显示与“id”值对应的“word”
我面临的主要障碍是:
我正在生成数字“11111”,我需要一种仅使用生成的数字“11111”来显示相应单词的方法,有没有办法实现?
【问题讨论】:
标签: c# asp.net asp.net-core razor razor-pages