Creating 28 checkboxes with a common name and different values There are 28 check boxes that are given a common name and have different values:



&lt;input type="checkbox" name="Schedules" id="checkbox1" value="1"&gt;


In controller in post action:



public ActionResult Create(SubscriptionPlanCreateViewModel subscriptionPlanCreateViewModel, FormCollection Form)
{
    string[] AllStrings = Form["Schedules"].Split(',');
    foreach (string item in AllStrings)
    {
        int value = int.Parse(item);
        if (value == 1)
        {
            subscriptionPlanCreateViewModel.Timeschedule = "OneTime";
        }
    }
}


By using this code I need to use 28 if conditions. How can I reduce the code size?
It seems to me that what you really need to do is change the view code. For example, if you do this:

&lt;input type="checkbox" name="Timeschedule" id="checkbox1" value="OneTime"&gt;
&lt;input type="checkbox" name="Timeschedule" id="checkbox2" value="Weekly"&gt;


That will automatically bind to the Timeschedule property on your SubscriptionPlanCreateViewModel. However, if the user selects multiple checkboxes, the values will probably come across as comma-separated. You can either make Timeschedule an array (which would probably better represent what you're doing from a data perspective) or you can simply replace the commas with " | " to produce the string you say you want in your comments.