DotnetSparrow
DotnetSparrow

Reputation: 27996

groupname @Html.radiobutton

I have created radio button like this:

 @foreach (LoanQuestionIncludesStatement statement in item.Statements)
                {
                    _question = statement.Question;
                    @Html.RadioButton("_Q_" + counter.ToString("0#") + _question.ToString(), false, new { @class = "answer " + qOrderedClass, id = "_Q_" + questionOrderedNumber }) @statement.Statement
                    @Html.Hidden("_S_" + counter.ToString("0#") + _question.ToString(), statement.KeyOrStatement) 
                    <br />
                    counter++;
                }

but they are not grouped. Mean I can check all the radio buttons. I want one of the radio button from each group to be checked. How to specify groupname ?

Upvotes: 0

Views: 882

Answers (2)

Anders Arpi
Anders Arpi

Reputation: 8397

Try including a "name" value in the new { @class = "answer " + qOrderedClass, id = "_Q_" + questionOrderedNumber }, as is always needed when creating radio button groupings.

Upvotes: 1

Michal B.
Michal B.

Reputation: 5719

Does this solve your problem: http://jonlanceley.blogspot.com/2011/06/mvc3-radiobuttonlist-helper.html ?

Upvotes: 0

Related Questions