How to pass an enum to Html.RadioButtonFor to get a list of radio buttons in MVC 2 RC 2, C#

Posted by Matt W on Stack Overflow See other posts from Stack Overflow or by Matt W
Published on 2010-02-08T15:46:42Z Indexed on 2010/05/13 2:04 UTC
Read the original article Hit count: 1728

Filed under:
|
|

Hi, I'm trying to render a radio button list in MVC 2 RC 2 (C#) using the following line:

<%= Html.RadioButtonFor(model => Enum.GetNames(typeof(DataCarry.ProtocolEnum)), null) %>

but it's just giving me the following exception at runtime:

Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.

Is this possible and if so, how, please?

Thanks,

Matt.

© Stack Overflow or respective owner

Related posts about exception

Related posts about c#