HTML formatting inside radio button list?

Mike521

Freshman
Joined
May 3, 2004
Messages
27
Hey all,

I'm converting an ASP form into ASP.net. There was a radio button section in the ASP form, where each radio button was in it's own table cell.

I'd like to have similar formatting in ASP.net, with a radiobuttonlist. However I get an error when I try to load the form because the td cell is not accepted in a radiobuttonlist. Is there a way to do this without going too crazy? If I have to just put all the buttons next to each other in a cell then I'll do it.

Here's the error:

Code:
Parser Error Message: System.Web.UI.WebControls.ListItemCollection must have items of type 'System.Web.UI.WebControls.ListItem'. 'td' is of type 'System.Web.UI.HtmlControls.HtmlTableCell'.

Line 239:        
Line 240:   </td>
Line 241:   <td width="22%">
Line 242:    <p>
Line 243:    <font size="1" face="Verdana, Arial, Helvetica, sans-serif">

Here's a source code snipet:

Code:
<td>

<asp:radiobuttonlist ID="rblPrimeInt" runat="server">
<asp:listitem 

	id="rblDoc" 
	runat="server" 
	Value="Document Conversion Services" />

</td>
<td width="22%">

<asp:listitem 
	id="rblScan" 
	runat="server" 
	Value="Scanners" />
</td>

<td width="25%">

<asp:listitem 
	id="rblSoft" 
	runat="server" 
	Value="Software" />
</td>
                        
<td width="25%">


<asp:listitem 
	id="rblOther" 
	runat="server" 
	Value="Other" />

</asp:radiobuttonlist>

</td>


thanks :)
 
This may or may not work for you but it might be something to experiment with.

The radiobuttonlist has a few properties you can manipulate to make it display AS a table. For example, if you set 'repeatlayout' to 'table' it'll wrap all of your radio buttons in an html table structure for you. There are lots of other properties you can manipulate, including giving it all a css class if you want, to get more control over the final appearance. I'm not sure if there is a way to give a style, class or specific width to each individual table cell that gets generated though.

Ex:

Code:
<asp:radiobuttonlist id="rblTest" repeatlayout="Table" repeatdirection="Horizontal" cssclass="test" runat="server">
<asp:listitem value="1">Item 1</asp:listitem>
<asp:listitem value="2">Item 2</asp:listitem>
<asp:listitem value="3">Item 3</asp:listitem>
</asp:radiobuttonlist>

Paul
 
Back
Top