How to make to RadioButtonList on the same group

J

John Dow

I have two RadioButtonList that binding two seperate lists. However, I
would like to make them in the same group, which means when one
RadioButtonList has any selected item, the other RadioButtonList will have
no selected item.

Is there any way to do that easily?

Thanks
 
M

Mansi Shah

Hello John,


You want that when one RadioButtonList has any selected item, the other
RadioButtonList will have
no selected item.

So, for this you can use this sample code. Hope this will help you.
For this you have to set "AutoPostBack" property of Checkboxlist to
"True".

And then write the following code:

protected void RadioButtonList1_SelectedIndexChanged(object sender,
EventArgs e)
{
for (int i = 0; i < RadioButtonList1.Items.Count; i++)
{
if (RadioButtonList1.Items.Selected == true)
{
for (int j = 0; j < RadioButtonList2.Items.Count; j++)
RadioButtonList2.Items[j].Selected = false;
break;
}
}
}

Mansi Shah.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,265
Messages
2,571,069
Members
48,771
Latest member
ElysaD

Latest Threads

Top