0

I wrote this code:

<select id="selectCategories" runat="server">
    <option value="-1">Categories</option>
    <asp:ListView ID="lvCategories" runat="server">
        <ItemTemplate>
            <option value="<%# Eval("ID") %>"><%# Eval("NAME") %></option>
        </ItemTemplate>
    </asp:ListView>
</select>

and the browser gave me: 'HtmlSelect' cannot have children of type 'ListView'.

I dont want to insert the select into the listview or remove the runat from the select. What can I do?

Nir
  • 2,497
  • 9
  • 42
  • 71

1 Answers1

-1

a select element can only contain option or optgroup elements

try the optGroup element

https://developer.mozilla.org/en/HTML/Element/optgroup

also, the following video will teach you how to do what you are trying to

http://www.asp.net/web-forms/videos/how-do-i/how-do-i-use-the-ability-to-create-groups-with-the-listview-control-for-different-data

lostinplace
  • 1,538
  • 3
  • 14
  • 38