0

I have a two sets of Enums to generate list of radio button list. 1) To generate labels of available features and 2) To generate fix set of values as radio buttons. How to bind such radio button values to model in order to post them to controller? My UI would be something like below:

Available Features:

PublicAPI

Enabled  Disabled

PrivateAPI

Enabled Disabled

Authentication

Enabled Disabled

Below is my model:

public enum Features
    {
        PublicAPI = 1,
        PrivateAPI,
        Authentication
    }

public enum FeatureState
    {
        Enabled,
        Disabled,
    }

public class MyModel
{
public Dictionary<Features, FeatureState> FeatureSettings{ get; set; }
}

1 Answers1

0

What I have tried , I don't know weather do you want output should look like this or whatafter debugging

       public enum Features
    {
        PublicAPI = 1,
        PrivateAPI,
        Authentication
    }

    public enum FeatureState
    {
        Enabled,
        Disabled,
    }
    public Dictionary<Features, FeatureState> FeatureSettings { get; set; }


    public ActionResult Index()
    {

        FeatureSettings = new Dictionary<Features,FeatureState>();
        foreach (Features foo in Enum.GetValues(typeof(Features)))
        {
            FeatureSettings.Add((Features)foo, (FeatureState)foo);
        }

        return View();
    }
Chand Jogani
  • 146
  • 12