Home All Groups Group Topic Archive Search About

How to make to RadioButtonList on the same group

Author
17 Oct 2007 5:05 AM
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

Author
17 Oct 2007 10:26 AM
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[i].Selected == true)
    {
     for (int j = 0; j < RadioButtonList2.Items.Count; j++)
        RadioButtonList2.Items[j].Selected = false;
     break;
     }
  }                   
}

Mansi Shah.

*** Sent via Developersdex http://www.developersdex.com ***
Author
18 Oct 2007 4:06 AM
John Dow
Mansi ,

That works.  Thanks so much.!


Show quote
"Mansi Shah" <ma***@devdex.com> wrote in message
news:OEQZ6gKEIHA.3980@TK2MSFTNGP03.phx.gbl...
> 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[i].Selected == true)
>    {
>     for (int j = 0; j < RadioButtonList2.Items.Count; j++)
>        RadioButtonList2.Items[j].Selected = false;
>     break;
>     }
>  }
> }
>
> Mansi Shah.
>
> *** Sent via Developersdex http://www.developersdex.com ***
Author
18 Oct 2007 5:27 AM
Mansi Shah
You are always Welcome John!

Mansi Shah.

*** Sent via Developersdex http://www.developersdex.com ***

AddThis Social Bookmark Button