2008-10-17 3 views
4

베타 버전으로 업그레이드 한 후 Html.RadioButtonList에 문제가 있습니다. 누군가 내가 잘못하고있는 것을 보여줄 수 있습니까?RadioButtonList 예외

코드 :

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

내가 얻을 예외 : 사전에

[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 

많은 감사합니다!
Rob

답변

4

MVC 프레임 워크에서 버그를 발견 한 것 같습니다. RadioButtonList의 다른 오버로드는 잘 작동하지만 특정 overload barfs가 작동합니다. 상황이이 라인에 비스듬히 이동처럼 보이는 리플렉터보고 (스택 추적을 사용하여)에서

다음 Microsoft.Web.Mvc.RadioListExtensions.RadioButtonListInternal 방법에

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

. 미리보기 5에서이 코드가 제대로 작동했다고 가정합니다.

+0

거룩한 암소, 제이슨! 우리는 BT에서 짧은 시간 동안 함께 일했습니다. 서명이 베타 버전으로 변경되었습니다. 전에는 Html.RadioButtonList ("유권자"+ 유권자 .Id, 새로운 [] { "예", "아니오", "기권"}, "예")를 사용했으며 챔피언처럼 작동했습니다. – Rob

+1

예, 기억합니다. 실제로 메서드를 작동시킬 수있는 모든 방법을 시도했지만 실제로 SelectList 형식 일 때만 전달됩니다. 나는 이것이 누구에게나 효과가 있는지 듣고 싶습니다. –

관련 문제