How to make to RadioButtonList on the same group

Discussion in 'ASP .Net Web Controls' started by John Dow, Oct 17, 2007.

  1. John Dow

    John Dow Guest

    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
     
    John Dow, Oct 17, 2007
    #1
    1. Advertising

  2. John Dow

    Mansi Shah Guest

    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.

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Mansi Shah, Oct 17, 2007
    #2
    1. Advertising

  3. John Dow

    John Dow Guest

    Mansi ,

    That works. Thanks so much.!


    "Mansi Shah" <> wrote in message
    news:...
    > 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.
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
     
    John Dow, Oct 18, 2007
    #3
  4. John Dow

    Mansi Shah Guest

    Mansi Shah, Oct 18, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Akaketwa
    Replies:
    1
    Views:
    4,904
    impaler
    Sep 22, 2006
  2. Replies:
    0
    Views:
    537
  3. christopher taylor
    Replies:
    0
    Views:
    411
    christopher taylor
    Sep 17, 2008
  4. cpld-fpga-asic
    Replies:
    13
    Views:
    1,197
    rickman
    Jul 6, 2009
  5. Dag Sunde
    Replies:
    0
    Views:
    122
    Dag Sunde
    Nov 18, 2005
Loading...

Share This Page