Help needed with RadioButtons!

Last post 06-02-2009 12:11 AM by getchinna_sv. 5 replies.

Sort Posts:

  • Help needed with RadioButtons!

    06-01-2009, 10:46 PM
    • Member
      19 point Member
    • cypher_jy
    • Member since 05-06-2009, 2:08 AM
    • Posts 41

    Hi. I need to do something like this:

    There is a table with 2 columns and 4 rows with a RadioButton in each column and i need to make sure that the user is able to select 1 RadioButton vertically and horizontally.

    So can a RadioButton be assigned with more than 1 GroupName? 

  • Re: Help needed with RadioButtons!

    06-01-2009, 11:10 PM
    • All-Star
      94,406 point All-Star
    • vinz
    • Member since 10-05-2007, 11:47 AM
    • Cebu, PH
    • Posts 13,998
    • TrustedFriends-MVPs

    For that case then you can use RadioButtonList instead since it has an attribute RepeatColumns which allows you to set the number of columns the RBL will display.

    Here's an example:

     

        <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatColumns="2">
        <asp:ListItem>A</asp:ListItem>
        <asp:ListItem>B</asp:ListItem>
        <asp:ListItem>C</asp:ListItem>
        <asp:ListItem>D</asp:ListItem>
        <asp:ListItem>E</asp:ListItem>
        <asp:ListItem>F</asp:ListItem>
        <asp:ListItem>G</asp:ListItem>
        <asp:ListItem>H</asp:ListItem>
        </asp:RadioButtonList>
      


    "Code,Beer and Music ~ my way of being a programmer"



  • Re: Help needed with RadioButtons!

    06-01-2009, 11:35 PM
    • Star
      10,552 point Star
    • getchinna_sv
    • Member since 09-10-2008, 4:29 PM
    • Hyderabad
    • Posts 1,807

    Instead of going for radiobutton with table.. you can use RadioButtonList with multiple columns.....

     

    Chinna_sv...
  • Re: Help needed with RadioButtons!

    06-01-2009, 11:37 PM
    • Member
      19 point Member
    • cypher_jy
    • Member since 05-06-2009, 2:08 AM
    • Posts 41

    Thanks for the swift reply. I have tried your method and it only allows me to select only one radio button from both columns which is not what i am looking for.

    There is a table with 2 columns and 4 rows of radio buttons(RB). Its compulsory for the user to select only 1RB from the 1st column and only 1RB from the 2nd column, plus the user can only select 1RB per row.

    Any idea to this?

     

  • Re: Help needed with RadioButtons!

    06-02-2009, 12:07 AM
    Answer
    • All-Star
      94,406 point All-Star
    • vinz
    • Member since 10-05-2007, 11:47 AM
    • Cebu, PH
    • Posts 13,998
    • TrustedFriends-MVPs

    cypher_jy:
    Its compulsory for the user to select only 1RB from the 1st column and only 1RB from the 2nd column, plus the user can only select 1RB per row.
     

    You can use JavaScript to validate.. here's an example for your reference:

     

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
            <script type="text/javascript" language="javascript">
            function Validate(obj1, obj2)
            {
                var box1 = document.getElementById(obj1);
                var box2 = document.getElementById(obj2);
                 
                if(box1.checked == true)
                {
                    box2.checked = false;
                }
                
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:RadioButton ID="RadioButton1" runat="server" GroupName="demoGroup"  onclick="Validate('RadioButton1','RadioButton4');"
                Text="Test1" />       
                <asp:RadioButton ID="RadioButton4" runat="server" GroupName="demoGroup1"  onclick="Validate('RadioButton4','RadioButton1');"
                Text="Test4" />
            <br />
            <asp:RadioButton ID="RadioButton2" runat="server" GroupName="demoGroup" onclick="Validate('RadioButton2','RadioButton5');"
                Text="Test2" />
                <asp:RadioButton ID="RadioButton5" runat="server" GroupName="demoGroup1" onclick="Validate('RadioButton5','RadioButton2');"
                Text="Test5" />
            <br />
            <asp:RadioButton ID="RadioButton3" runat="server" GroupName="demoGroup" onclick="Validate('RadioButton3','RadioButton6');"
                Text="Test3" />
            <asp:RadioButton ID="RadioButton6" runat="server" GroupName="demoGroup1" onclick="Validate('RadioButton6','RadioButton3');"
                Text="Test6" />
            <br />
        </div>
        </form>
    </body>
    </html>
    
      


    "Code,Beer and Music ~ my way of being a programmer"



  • Re: Help needed with RadioButtons!

    06-02-2009, 12:11 AM
    Answer
    • Star
      10,552 point Star
    • getchinna_sv
    • Member since 09-10-2008, 4:29 PM
    • Hyderabad
    • Posts 1,807
Page 1 of 1 (6 items)