Hi, I am dealing with AJAX UpdataPanel. I created 2 radio button during run time. By default there is a button in the updatepanel.
A user will check either one radiobutton in updatepanel and then hit the button.

How do i got to know which radiobutton is checked?

RadioButton rb1 = new RadioButton();
        RadioButton rb2 = new RadioButton();
        rb1.ID = "rb1";
        rb2.ID = "rb2";
        rb1.GroupName = "group1";
        rb2.GroupName = "group1";
        rb1.Text = "Yes";
        rb2.Text = "No";
        UpdatePanel1.ContentTemplateContainer.Controls.Add(rb1);
        UpdatePanel1.ContentTemplateContainer.Controls.Add(rb2);

It is possible to loop through all the control and check which radiobutton is checked? The number of radiobutton and it's id is retrieved from database. Which mean, no fix amount of radiobutton and no fix id. Only one group of radiobutton will be tabulated once. Hope this will clarify the problem.

I tried to stored the id of dynamic radiobuttons into session and reference them by:

RadioButton tb = new RadioButton();
tb = (RadioButton)UpdatePanel1.ContentTemplateContainer.FindControl("rb1");
if (tb != null)
Label1.Text = tb.Text;

I found that if i create the dynamic control in page_load then i will sucessfully reference to the dynamic control but if it is not created in page_load then I couldnt reference to the radiobutton. The function of mine is to dynamically tabulate the radiobuttons into updatepanel when a question is pick in a updatepanel. Any sugguestion to solve the problem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.