How to allow html control inside a listitem?

Masud Rahman picture Masud Rahman · Sep 16, 2010 · Viewed 9.8k times · Source

The following compile error occurs:

Parser Error Message: The 'Text' property of 'asp:ListItem' does not allow child objects.

Source Error:

Line 468: </asp:ListItem>
Line 469: <asp:ListItem Value="3">
Line 470: Search only continuing stories with at least&nbsp; <input runat="server" id="episodetb" Value="0" style="width:50px" />
Line 471: episodes
Line 472: </asp:ListItem>

When my original code is like this:

< asp:RadioButtonList ID="ContStoryRadioButtonList" DataTextFormatString=" {0}" CellPadding="2" runat="server">
<asp:ListItem Value="0">
Search singular and continuing stories
</asp:ListItem>
<asp:ListItem Value="1">
Search only singular stories
</asp:ListItem>
<asp:ListItem Value="2">
Search only continuing stories
</asp:ListItem>
<asp:ListItem Value="3">
Search only continuing stories with at least&nbsp; <input runat="server" id="episodetb" Value="0" style="width:50px" />
episodes
</asp:ListItem>
</asp:RadioButtonList >

Please help me with this. thx in advance

Answer

Joachim VR picture Joachim VR · Sep 16, 2010

Unfortunately a ListItem object doesn't have any child controls. You could write your own control doing something similar. Basically you just have to write a <ul> tag with <li/> subitems.