[RESOLVED] RadioButtonList inside parent RadioButtonList

I am writing a form which has a set of options (radio buttons), and under each option, there is another set of options.  For example:

 - Session 1

      - New Book A

      - Used Book A

- Session 2

      - New Book B

      - Used Book B

I've tried using HTML <input type="radio", and <asp:RadioButton, but even though I assign the "name" attribute correctly, the buttons are not mutually exclusive -- i.e., you can click both within each group.  I see in "View Source" that the name and ID are altered, and therefore become ungrouped by the ASP.NET processing.

I've tried using <asp:RadioButtonList, and this works functionally, but the items are not grouped properly.  They appear like this:

- Session 1

- Session 2

      - New Book A

      - Used Book A

      - New Book B

      - Used Book B

I have not been able to find a solution to this problem, and would appreciate any help...

Thank you for responding.  The link you provided says, "Based on my research and experience, I think that it is impossible tocreate "nested radio button lists" using VS.NET"...

niksv

 http://bytes.com/topic/asp-net/answers/290891-nested-radiobuttonlists
 

I'm beginning to believe this, but it seems incredible to me that ASP.NET web forms cannot handle this.  I know this can be done with classic ASP (because I am converting an old web app which does this).  It also uses javascript to select the parent button if a child option is selected.  I will keep trying, and will post my result.


Please try this

//aspx
<form id="form1" runat="server">
    <div>
    

    </div>
    <br />
    <span>XXXXXXX</span>
    <br />
    <input id="RadioButtonList2_0" type="radio" name="RadioButtonList2" value="A" /><label for="RadioButtonList2_0">AAA</label>
    <br />
    <input id="Radio1" type="radio" name="RadioButtonList2" value="B" /><label for="RadioButtonList2_0">BBb</label>
    <br />
    <input id="Radio2" type="radio" name="RadioButtonList2" value="C" /><label for="RadioButtonList2_0">ccc</label>
    <br />
    <span>ZZZZZZZZ</span>
    <br />
    <input id="Radio3" type="radio" name="RadioButtonList2" value="D" /><label for="RadioButtonList2_0">ddd</label>
    <br />
    <input id="Radio4" type="radio" name="RadioButtonList2" value="E" /><label for="RadioButtonList2_0">eee</label>
    <br />
    <input id="Radio5" type="radio" name="RadioButtonList2" value="F" /><label for="RadioButtonList2_0">ffff</label>




    

    </form>


 

Thank you, but it's not really what I'm looking for.  I would like to put the parent radio buttons where you have the XXXXXXX and ZZZZZZZ text.  Also, I need to databind the parent radio buttons first.  When each parent item is created, I need to databind the corresponding child radio buttons based on a datakey from the parent datasource.


I could easily do something similar using ListViews, for example, using the parent ListView's ItemDataBound event to create a child ListView, but RadioButtonList does not have something like ItemDataBound.


I tried doing this using nested ListViews, and creating the individual radio buttons as HTML or ASP.NET server controls as described in my original post, but that (surprisingly) doesn't work because the "name" (HTML) or "GroupName" values I assign are not retained, and even though the page renders as I would like it to look, the radio buttons become ungrouped and useless.

Please refer this ([decker dong - msft]'s answer)  workaround here , for a similar situation like yours.

http://forums.asp.net/t/1458411.aspx

Hope this helps. 

Thank you, that does work for the scenario I posted.  

Unfortunately, I simplified my problem for posting, and ultimately, I need to place these radio buttons within a Repeater or ListView to produce additional layers and perform addition event handling.  I finally found that there is actually a bug in ASP.NET (http://support.microsoft.com/kb/316495) which prevents radio buttons from being mutually exclusive when used within a Repeater or ListView.  I've looked for a solution or workaround, but have not found one.  If you know of any, please let me know.  I am also going to ask for this in a new and separate thread.

Thanks again for your help!

thoughts on "[RESOLVED] RadioButtonList inside parent RadioButtonList"

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>