Click here to Skip to main content
15,067,335 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
Posted
Updated 2-Apr-21 1:50am
v4
Comments
   
"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.
—SA

Hi,

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 ADO.net 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.

Thanks,
   
Comments
Sharan Khanal 4-Sep-14 2:10am
   
Thank you for your comment!
I have already found the solution at
https://stackoverflow.com/questions/5522478/sql-query-for-tree-table/5522641#5522641?newreg=545a4de722f94bb89a20113dae61e543
I Found the solution
Here
   

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