【发布时间】:2017-07-12 14:56:08
【问题描述】:
我不得不更改一个单选按钮以包含一个新值。 为此,我必须将 Dictionary 放入 IDictionary 中。键非常适合 IDictionary,但 Dictionary int 和 string 根本不适合。 我相信这是我的前端代码。 谁能看到我做错了什么并提供如何解决的示例?
控制器中的动作参数
IDictionary<String, Dictionary<int, String>>
查看
<fieldset>
<legend class="sr-only">Actions</legend>
<input type="hidden" name="customerId" value="@account.CustomerId" />
<input type="hidden" name="yearSetupId" value="@account.YearId" />
<label class="radio-inline"><input type="radio" name="accountActions[@(account.CustomerId)].Key[@(account.Id)].Value" value="" checked="checked">Do nothing</label>
@{
var possibleActions = account.Balance < 0 ? new[] {
BalanceAdjustmentType.Zeroed, BalanceAdjustmentType.Issued }
: new[] { BalanceAdjustmentType.Under, BalanceAdjustmentType.Sent };
}
@foreach (var action in possibleActions)
{
<label class="radio-inline"><input type="radio" name="accountActions[@(account.CustomerId)].Key[@(account.YearId)].Value" value="@action.BalanceId">@action.Text</label>
}
</fieldset>
【问题讨论】:
标签: c# asp.net-mvc dictionary razor