1
Answer

Change radio button group name programatically

ashish siwalkar

ashish siwalkar

11y
1.1k
1

I tried to change radio buttons group name from code behind file. It will apply only when I refresh the page. I want to apply it on condition after button click. what can I do.

        Label1.Text = question[i].get_question().ToString();
        RadioButton1.Text = question[i].get_option1().ToString();
        RadioButton2.Text = question[i].get_option2().ToString();
        RadioButton3.Text = question[i].get_option3().ToString();
        RadioButton4.Text = question[i].get_option4().ToString();

        if (question[i].get_type().ToString() == "Single")
        {

            RadioButton1.GroupName = "ans";
            RadioButton2.GroupName = "ans";
            RadioButton3.GroupName = "ans";
            RadioButton4.GroupName = "ans";

        }   

else if (question[i].get_type().ToString() == "Multiple") {

            RadioButton1.GroupName = "ans1";
            RadioButton2.GroupName = "ans2";
            RadioButton3.GroupName = "ans3";
            RadioButton4.GroupName = "ans4";
        }

But it apply at next assignment of radio button.

Answers (1)