我使用 Dictionary<string,string> 来存储一些选项,键是选项的名称,正如您猜测的那样,该值是相应选项的值。
在我的剃刀文件中,我有这段代码:
@foreach (KeyValuePair<string, string> option in templates.templatesList[SelectionValue])
{
<tr>
<td>@option.Key</td>
<td><input type="text"/></td>
</tr>
}
Run Code Online (Sandbox Code Playgroud)
我要做的是将文本输入的值存储到字典中的正确值中,遗憾的是我们不能使用@bind = @option.Value。