【发布时间】:2020-07-01 14:35:23
【问题描述】:
我正在使用 Dictionary
在我的剃须刀文件中,我有这段代码:
@foreach (KeyValuePair<string, string> option in templates.templatesList[SelectionValue])
{
<tr>
<td>@option.Key</td>
<td><input type="text"/></td>
</tr>
}
我正在寻找的是将文本输入的值存储到我的字典中的正确值中,遗憾的是我们不能使用@bind = @option.Value。
【问题讨论】:
-
为什么不能使用@bind = option.Value
-
好像值是只读类型的,不能修改,至少razor文件里不能修改
-
尝试绑定templates.templatesList[SelectionValue][option.Key]
-
@Vi100 键和值是只读的,因此在对象类之外很难超越它,我提出了一个可以正常工作的临时解决方案。
标签: c# blazor blazor-server-side asp.net-blazor