mtnwk
mtnwk

Reputation: 83

adding text between items on radio button control list

I need to add some text between the list items, but I haven't seen a way to do this. I've looked at adding space between the items, but I can't figure out how to add text between the list items.

    <asp:RadioButtonList ID="RadioButtonList1" runat="server" >
 need to add text here
    <asp:ListItem Value="10.00" Selected="True">this is item1</asp:ListItem>
 need to add text here
    <asp:ListItem Value="10.00">this is item2 </asp:ListItem>
 need to add text here
    <asp:ListItem Value="10.00"> this is item3 </asp:ListItem>

</asp:RadioButtonList>

Upvotes: 1

Views: 2097

Answers (2)

tenorsax
tenorsax

Reputation: 21223

You can use several RadioButton controls to achieve that, also group them if needed.

RadioButtonList will not allow you to insert text in between. Here is a quote from MSDN:

The RadioButtonList control does not permit you to insert text between the buttons, but is far easier to use if you want to bind the buttons to a data source. It is also slightly easier to write code that checks which button has been selected.

Upvotes: 1

TheGeekYouNeed
TheGeekYouNeed

Reputation: 7539

I would create a custom RadioButtonList control so that you can implement your own custom ListItem type and render the values in your customer ListItem's properties appropriately.

ListItem is sealed, so you can't inherit from it. However you could make your own class that mimics ListItem, and add a couple more properties for the addition text you want to be able to display per list item.

Then, in the Render method of your custom Radio Button List, you could render a tag and your text in between those before outputting the normal list item properties - text and value.

HTH

Upvotes: 0

Related Questions