ASP.NET 4 General DiscussionFor ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
I want to know that how we can design a table so that it contains the Parent and Child elements in itself? There should not be two separate tables for each element connected through foreign key constraint.
For example we may consider Category section in any web application. Where Categories, SubCategories, SubSubCategories, upto as many level as you want should be in single table.
Kindly tell me how to design such table and how to code to enter elements in such table in web forms?
only two columns required and neither u need to create primary foreign key relation nor size of db would increase as happens in case of denormalization.
only two columns required and neither u need to create primary foreign key relation nor size of db would increase as happens in case of denormalization.
sry 4 replying late.
u may use a tree view
set parentid of topmost categories to 0.
insert nodes with text of these categories names,then find those subcategories which come under these categories and add then to there corresponding parent nodes.
id name parentid
1 electronics 0
2 jewelry 0
3 pc 1
4 kitchen 1
5 ups 3
6 monitor 3
7 juicer 4
8 otg 4
Hi Sam,
No need to be sorry. Well in the meanwhile I had applied the some procedure that you mentioned. I kept ParentId = 0 for parent category. The only thing I need is to collect the parent child list and display them into Dropdownlist and repeater. I do not wanna use TreeView, as it will not solve the situation what a repeater can.