1

I have developed a form in asp.net mvc3 which has multiple options to choose from. Please see the below image for clear picture. There are two groups "Accommodation" and "Pick up and drop" and these groups have multiple options to choose from. User should select only one option from each group but here I can select only one option from entire options i.e. I'm not able to choose both "Single sharing" and "Pick up and drop". Is there any way I can distinguish between two radio button groups?

 foreach (var facilityType in facilityTypeGroup.ProductPriceDisplayFacility)
                       {

                    <tr>
                        <td>
                            @Html.RadioButtonFor(m => m.SelectedChoice, @facilityType.FacilityTypeId + "_" + @facilityType.Price)
                            @facilityType.FacilityTypeName    </td>
                    </tr>

                       }

enter image description here

1
  • Hi! I have similar query like yours. Can you share how you solve your question? Commented Jun 8, 2013 at 5:31

1 Answer 1

2

To make them behave as a group, checkboxes in the same group must have the same name attribute. Then it's easy to either use the ModelBinder or the Request object to get the selected value.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks aligray, I understood that giving same name would solve my problem. But my next problem is groups are dynamic i.e.they vary in different cases. So i can set model property to GroupId in controller. Can I set property value in razor in above given foreach loop?
I think in this case, generating the raw html for the checkboxes yourself will be the best option.
Hi Pramodtech, i have a similar problem. Can you please share your fix? Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.