首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >RadioButtonList异常

RadioButtonList异常
EN

Stack Overflow用户
提问于 2008-10-17 23:51:55
回答 1查看 1.6K关注 0票数 4

在我升级到测试版之后,我在使用Html.RadioButtonList时遇到了麻烦。有人能告诉我我哪里做错了吗?

代码:

代码语言:javascript
运行
复制
<% Html.RadioButtonList(
    "voter" + voter.Id,
    new SelectList(new[]{"yes","no","abstain"}, "yes")).Each(x => Response.Write(x)); %>

我得到的例外是:

代码语言:javascript
运行
复制
[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

首先要感谢大家!

抢夺

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2008-10-18 04:57:01

看起来你可能在MVC框架中发现了一个bug。RadioButtonList的其他重载看起来工作得很好,但那个特定的重载是无用的。

通过查看Reflector (并使用堆栈跟踪),我发现下面这一行出了问题:

代码语言:javascript
运行
复制
    return selectList.GetListItems().Select<ListItem, string>(delegate (ListItem item) {
    return htmlHelper.RadioButton(name, item.Value, item.Selected, htmlAttributes);
}).ToArray<string>();

在Microsoft.Web.Mvc.RadioListExtensions.RadioButtonListInternal方法中。我假设这段代码在预览版5中运行得很好?

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/214210

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档