Problem with DIV in ASP Components

I have a radio button with a div around it, as plain HTML it's fine but as soon as convert the HTML radion buttons into
ASP equivalents using RadioButtonList component the div  throws an error. How can I apply the div to the  RadioButtonList  without it throwing up errors?

Below is the ASP version throwing the error

<div id="checkgrouping" runat="server">
            <asp:RadioButtonList id="RadioButtonList1" runat="server">
                  <div id="checkgrouping" runat="server">
                  <asp:listitem id="webSearch" runat="server" value="Web Search"/>

When I run the application I get the following runtime error:

Parser Error Message: System.Web.UI.WebControls.ListItemCollection must have items of type 'System.Web.UI.WebControls.ListItem'. 'div' is of type 'System.Web.UI.HtmlControls.HtmlGenericControl'.

Any ideas ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


The page does not like the inner <div> inside the RadioButtonList control. You have to remove it. Any reason why you have such a tags?

And also the asp:RadioButtonList close tag </asp:RadioButtonList> does not exists. The following tags should work.

                  <div id="checkgrouping" runat="server">
                        <asp:RadioButtonList id="RadioButtonList1" runat="server">
                                    <asp:listitem id="webSearch" runat="server" value="Web Search" />


You don't really need the RadioButtonList you could just add a groupname then you can use your div

<div id="checkgrouping" runat="server">

<asp:RadioButton id="RadioButton1" GroupName="MyGroup"></asp:RadioButton>
<asp:RadioButton id="RadioButton2" GroupName="MyGroup"></asp:RadioButton>
<asp:RadioButton id="RadioButton3" GroupName="MyGroup"></asp:RadioButton>
<asp:RadioButton id="RadioButton4" GroupName="MyGroup"></asp:RadioButton>




Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
q2004Author Commented:

The RadioButtonList method worked, the inner div had to be taken out i.e. the div around the listitem.

The second method; the RadioButton method worked fine but each RadioButton needs a Runat="Server" paramter so each one should read:

<asp:RadioButton id="RadioButton1" GroupName="MyGroup" Runat="Server" ></asp:RadioButton>

Enclosing the above in a div works fine.

As for the inner div the html template was designed to me that way,  it needs to be there for correct display, so I'll be using the second method. Although I'm puzzled why a RadioButtonList refuses to accept an inner div.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.