Search code examples
asp.netnestednested-checkboxes

Create nested checkboxes in asp.net 2.0


Whats is the best method to create nested checkboxlists in ASP.net?

Should I be using a datagrid? Should I be using a treeview with checkboxes enabled?

I have the data I need in a datatable, and would like to loop through through it to create a checkboxlist with a nested chechboxlist for each parent checkbox.

Cheers!


Solution

  • I've never been a fan of grids, instead, I use repeaters/listviews and for each row I have a UserControl that is responsible for showing the row data, and further repeaters for sub-data.

    Tiny example:

    <asp:repeater id... runat...>
        <itemtemplate>
            <uc1:MyRowControl id... runat... OnSomeEvent='MyRowHandler' Model='<%# (MySubData)Container.DataItem %>'
        </itemtemplate>
    </asp:repeater>
    

    and so on internally. Events is easy to handle when you do like this.