views:

892

answers:

0

I want a radio button generated with the Html.RadioButton() html helper to bind it's value to a field that has a struct as type.

Less abstract:

CommonProject.Services.SearchBag.Effects:

public enum Effects
{
    Any,
    Solid,
    Effect
}

In the strongly typed ViewData:

public class SearchBag{    
    public Effects EffectIndicator { get; set; }
}

And in my view(this doesn't really work):

<%=Html.RadioButton("SearchBag.EffectIndicator", "Any", ViewData.Model.SearchBag.EffectIndicatorIsAny, new { @id = "SearchBag.EffectIndicatorAny" })%>

UPDATE
It seems to work once..
Initially it creates the radiobuttons as desired, then when you change the value and post back, the value is correctly bound. Then on regenerating the page, all values of the buttons are set to the value you chose earlier on.