Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello I want to implement tree structure with few controls.
upto n level.
can any one give better solution or Suggestion!!
not getting any idea..!!

Please help me.


Example : Suppose I have a activity A1 which is connected to various department.
May be A1 can Contain's more than one child like A1.1, A1.2...... A1.N,and so on up-to n level
all Activity have the Same field Either in child or parent.
Posted
Updated 12-Aug-13 1:30am
v4
Comments
[no name] 7-Aug-13 5:57am    
Still your requirement is not clear. Please provide more information.
Maciej Los 7-Aug-13 15:55pm    
Agree!
OPees 8-Aug-13 1:19am    
Example : Suppose I have a activity A1 which is connected to various department.
May be A1 can Contain's more than one child like A1.1, A1.2...... A1.N,
all Activity have the Same field Either in child or parent.
Maciej Los 7-Aug-13 16:27pm    
Better to what?
What have you done so far? Where are you stuck?
OPees 8-Aug-13 1:24am    
Still i m not getting how to go about it.
trying with Creating dynamic controls but not succeed yet.

I assume you mean one of these controls[^],
 
Share this answer
 
Following Idea a basically an approach to start..
1) Start with a repeater or gridview with one or more columns. This will act as header for your data as it is databound control hence no hardcoding for record limitation means you can have 'n' records as parents.

2) In item template of Repeater or Gridview put a new Repeater or Gridview (as per your requitement) inturn it can have multiple records.

3) First bind your outer GridView with some set of data. In RowDataBound of outergrid find InnerGrid and bound it as per key.

4) So your data in place and you can design it any way you want.

5) As far as tree like structure concern Your outergrid items will have an Image (collapse/expand) that can show/hide adjacent inner grid.

Limitation -It will work only for 2 levels with n records each.

You can extend its behavior by investing more time :)
 
Share this answer
 
Comments
OPees 8-Aug-13 8:53am    
Thanks Sumit, for your suggestion , I tried to approach with Gridview already but for each level i have to bind the child grid that is the main problem..
sumit_kapadia 8-Aug-13 11:36am    
Yes, On each level you can bind grid on RowDataBound event. One more approch.. Instead of getting data for each child grid you can take entire dump in one go (including parent and child). then bind us by filtering datatable or linq whatever you use.
Maciej Los 12-Aug-13 7:38am    
Have you heard about nested gridviews?
Walkthrough: Creating a Nested GridView Control[^]
OPees 12-Aug-13 7:44am    
Yes, How can i achieve horizontally??
Maciej Los 12-Aug-13 7:48am    

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