Search code examples
asp.netsql-servervb.netradiobuttonlist

RadioButtonList Grouping In Labels


I need your help with this one, I don't know if it is possible.

Imagine a RadioButtonList populated from a Database using a databind from vb codebehind looking like this;

[1]  - Apple      -    Fruit  
[2]  - Banana      -   Fruit  
[3]  - Beetroot    -   Vegetable 
[4]  - Orange      -   Fruit   
[5]  - Strawberry  -   Fruit  
[6]  - Carrot      -   Vegetable  
[7]  - Potato      -   Vegetable

Now I want to make it look like this;

- [Fruit]
     - Apple
     - Banana
     - Orange
     - Strawberry
- [Vegetable]
     - Beetroot
     - Carrot
     - Potato

I think I am able to group the radio button somehow or change the label. I also thought about using a tree node which I have not used before.


Solution

  • OK you can not use attributes on radio buttons or list box items. The attribute is added to the parent only. You can achieve this by rewriting the DOM I have seen on another forum, requires a lot of the work I just will create 2 radio buttons to get me going. Its funny because if I was using PHP I could call a radio button list or select list and populate whatever attribute I wanted. Well Done Microsoft for removing this common use function! Just like the onkeyup events and ondblclick are only available client side.