custom layout : RadioButtonList

  • Thread starter Thread starter Christian H
  • Start date Start date
C

Christian H

Hi!

I'm wondering how I can add extra html to a radiobuttonList, so that I can
control how:
-the whole radioButtonList is rendered.
-each of the radiobutton elements are rendered.

What I am basically trying to do is to combine x radioButtonlists, so that
the output will look like this:
----------------------------------------------------------------------------
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>True</td>
<td>False</td>
<td>Don't know</td>
<td></td>
</tr>
<tr>
<td><input id="question_4_0_0" type="radio" value="9"
name="question_4_0"></td>
<td><input id="question_4_0_1" type="radio" value="10"
name="question_4_0"></td>
<td><input id="question_4_0_2" type="radio" value="-"
name="question_4_0"></td>
<td>&nbsp;Answer 1</td>
</tr>
<tr>
<td><input id="question_4_1_0" type="radio" value="1"
name="question_4_1"></td>
<td><input id="question_4_1_1" type="radio" value="2"
name="question_4_1"></td>
<td><input id="question_4_1_2" type="radio" value="-"
name="question_4_1"></td>
<td>&nbsp;Answer 2</td>
</tr>
<tr>
<td><input id="question_4_2_0" type="radio" value="1"
name="question_4_2"></td>
<td><input id="question_4_2_1" type="radio" value="2"
name="question_4_2"></td>
<td><input id="question_4_2_2" type="radio" value="-"
name="question_4_2"></td>
<td>&nbsp;Answer 3</td>
</tr>
</table>
----------------------------------------------------------------------------

The radiobuttonlists are dynamically created, using data from a database.
My idea was to add the <table> start and end tags manually as I am looping
through the database.

What I need though, is a way to :
-add <tr> start and end tags for each radioButtonlist
-add <td> start and end tags for each radioButton within each
radioButtonlist.

I imagine that there is a method I can override, that deals with the
creation of the radiobuttonlist, and that there also is a method I can
override, that creates the child elements (each radiobutton) within the
radiobuttonlist.

If anyone knows what methods I need to override, and how I do this, I would
really appreciate it.
 
Hi,

The easy way is to use the DataList Control (template with label and
radioButtonList). You can also create your own RadioButtonList control
that derived from RadioButtonList and override the Render method.

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
 
Back
Top