Click here to Skip to main content
15,664,506 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am building a comment based project, in which the user post comments and other can reply his/her comments.
I want to show the comments in nested form.For example:

1)Comment A
2)Reply TO Comment no 1
3)Reply tocomment no. 2

4)Reply to comment no 1
5) Reply tocomment no. 5

like wise.

I have a database tablble tbl_comment having columns

CommentID, CommentText, Date, time, ParentID

where parentID is the commentID for which the reply is made.
I having trouble in retrieving the tree view of comments
Updated 2-Apr-21 1:50am
Sergey Alexandrovich Kryukov 4-Sep-14 1:47am    
"I having trouble" is not informative. You did not explain a single problem in this post; this is not even a question.
This is not something which would require an expert's advice, just the work to be done. To get some help, you need to ask a question and formulate some problem very accurately, in sufficient detail.


You are retrieving data in hierarchical way.
If you are using any ORM like Entity Framework than it would be easy as it will generate all queries for you internally.
If you are using and you have to create a stored procedure to retrieve all data in a single table and you can convert them in tree view based on parent id. Easy solution to use is List<t> for tree view.

Share this answer
Sharan Khanal 4-Sep-14 2:10am    
Thank you for your comment!
I have already found the solution at
I Found the solution
Share this answer

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