简体   繁体   English

RadioButtonList异常

[英]RadioButtonList exception

After I upgraded to the beta, I'm having trouble with Html.RadioButtonList. 升级到测试版后,我遇到了Html.RadioButtonList的问题。 Can someone show me what I'm doing wrong? 有人能告诉我我做错了什么吗?

The code: 代码:

<% Html.RadioButtonList(
    "voter" + voter.Id,
    new SelectList(new[]{"yes","no","abstain"}, "yes")).Each(x => Response.Write(x)); %>

And the exception I get: 我得到的例外:

[ArgumentNullException: Value cannot be null.
Parameter name: value]
   System.Web.Mvc.Html.InputExtensions.RadioButton(HtmlHelper htmlHelper, String name, Object value, Boolean isChecked, IDictionary`2 htmlAttributes) +214
   Microsoft.Web.Mvc.<>c__DisplayClass1.<RadioButtonListInternal>b__0(ListItem item) in c:\dd\Cicero\src\Mvc\main\src\MvcFutures\Mvc\RadioExtensions.cs:86
   System.Linq.WhereSelectListIterator`2.MoveNext() +107
   System.Linq.Buffer`1..ctor(IEnumerable`1 source) +259
   System.Linq.Enumerable.ToArray(IEnumerable`1 source) +81
   Microsoft.Web.Mvc.RadioListExtensions.RadioButtonListInternal(HtmlHelper htmlHelper, String name, SelectList selectList, Boolean usedViewData, IDictionary`2 htmlAttributes) in c:\dd\Cicero\src\Mvc\main\src\MvcFutures\Mvc\RadioExtensions.cs:88
   Microsoft.Web.Mvc.RadioListExtensions.RadioButtonList(HtmlHelper htmlHelper, String name, SelectList selectList) in c:\dd\Cicero\src\Mvc\main\src\MvcFutures\Mvc\RadioExtensions.cs:29

Many thanks in advance! 提前谢谢了!
Rob

It looks like you may have found a bug in the MVC framework. 看起来您可能在MVC框架中发现了一个错误。 The other overloads of RadioButtonList seem to work just fine, but that particular overload barfs. RadioButtonList的其他重载似乎工作正常,但特定的重载barfs。

From looking at Reflector (and using the stack trace) I looks like things go awry at this line: 从查看Reflector(并使用堆栈跟踪),我看起来在这一行出了问题:

    return selectList.GetListItems().Select<ListItem, string>(delegate (ListItem item) {
    return htmlHelper.RadioButton(name, item.Value, item.Selected, htmlAttributes);
}).ToArray<string>();

In the Microsoft.Web.Mvc.RadioListExtensions.RadioButtonListInternal method. 在Microsoft.Web.Mvc.RadioListExtensions.RadioButtonListInternal方法中。 I assume this code worked fine in Preview 5? 我认为这个代码在预览5中运行良好?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM