Click here to Skip to main content
15,609,864 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

I am developing a project in which I am having checkboxlists, I want to add spaces between checkboxlist items, and i want the output like shown


Category1 and Category2 are checkboxlist populating from database, subcategories are also populating from database, am getting output as shown,


 Subcategory1(belongs to category1)
 Subcategory2(belongs to category1)

Subcategory1(belongs to category2)
Subcategory2(belongs to category2)

After selecting Category1, I want subcategories to be shown below that category with alignment as shown. please help me with code.
Updated 14-Jun-12 20:43pm
Sergey Alexandrovich Kryukov 15-Jun-12 0:57am    
ASP.NET? Tag it! Something else? -- don't blame me. It's not nice not to write fully qualified type name when asking such questions.

1 solution

You are trying to abuse the list, suggesting wrong replacement of structure with some alignment stuff using specially formatting string. This is called "fooling yourself". If you succeeded, how would you tell categories of different levels, also by text?

No, if you have categories and subcategories, this is a tree structure. If you have a tree structure, use a tree view. My guess is that you are using System.Web.UI.WebControls (why, why don't you properly tag what are you talking about in your question? there are different types with the same (non-qualifying names); it makes answering tricky? why asking this way?! proper tagging would take a couple of extra seconds, and not doing so wasted my time… why?!), so you could use System.Web.UI.WebControls.TreeView, and it has the property System.Web.UI.WebControls.TreeView.ShowCheckBoxes and the means to manipulate those check boxes:[^].

Share this answer
shabadiveda 15-Jun-12 2:44am    
i tried using treeview, bt the thing is the selected checkboxes are not getting inserted to database. I already asked so many times for the help also.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900