473,499 Members | 1,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to do a hierarchical listing of posting threads?

I want to display a hierarchical listing of items from a database
table, where, say, each row in the table has an "ID" field and a
"parent_id" field giving the ID of its parent (NULL if it's at the top
level of the hierarchy) -- like message posts and their replies. Is
there a built-in way to do this, or a generally accepted simplest way?

My first idea was to create a user control like HierarchicalListing
that contains a Repeater, and the repeater's ItemTemplate would itself
contain an instance of HierarchicalListing. Then when putting the
HierarchicalListing on the page, you set its DataSource and have it
query for all rows where the parent_id is null, and databind the
Repeater to the results -- and then inside the Repeater, look at the
ID of the current row, and for the HierarchicalListing inside the
Repeater, have it query for all rows where the parent_id was equal to
that ID. That would give you a hierarchical listing of all the rows,
if ASP.Net allowed it.

Unfortunately if you try adding
<%@ Register TagPrefix="uc1" TagName="HierarchicalPostListing"
Src="HierarchicalPostListing.ascx" %>
to the top of HierarchicalPostListing.ascx itself, you get a run-time
error that circular file references are not allowed.

So, is there a way for a user control to be nested inside itself (or
rather, to be nested conditionally inside itself, so you don't get an
infinite recursion)? More importantly, is there a generally accepted
way to do a hierarchical listing like what I'm trying to do?

-Bennett
Nov 18 '05 #1
3 2021
Perhaps what your looking for is a TreeView..
"Bennett Haselton" <be*****@peacefire.org> wrote in message
news:e6*************************@posting.google.co m...
I want to display a hierarchical listing of items from a database
table, where, say, each row in the table has an "ID" field and a
"parent_id" field giving the ID of its parent (NULL if it's at the top
level of the hierarchy) -- like message posts and their replies. Is
there a built-in way to do this, or a generally accepted simplest way?

My first idea was to create a user control like HierarchicalListing
that contains a Repeater, and the repeater's ItemTemplate would itself
contain an instance of HierarchicalListing. Then when putting the
HierarchicalListing on the page, you set its DataSource and have it
query for all rows where the parent_id is null, and databind the
Repeater to the results -- and then inside the Repeater, look at the
ID of the current row, and for the HierarchicalListing inside the
Repeater, have it query for all rows where the parent_id was equal to
that ID. That would give you a hierarchical listing of all the rows,
if ASP.Net allowed it.

Unfortunately if you try adding
<%@ Register TagPrefix="uc1" TagName="HierarchicalPostListing"
Src="HierarchicalPostListing.ascx" %>
to the top of HierarchicalPostListing.ascx itself, you get a run-time
error that circular file references are not allowed.

So, is there a way for a user control to be nested inside itself (or
rather, to be nested conditionally inside itself, so you don't get an
infinite recursion)? More importantly, is there a generally accepted
way to do a hierarchical listing like what I'm trying to do?

-Bennett

Nov 18 '05 #2
Hi Bennett:

I've done something similar previously. You might be interested in the
following:

Data Visualization Components
http://research.microsoft.com/resear...s/default.aspx
(About 1/3 the way down the screen).

Visualization Components for Persistent Conversations
http://research.microsoft.com/resear...0Report&id=407

--
Scott
http://www.OdeToCode.com

On 27 Sep 2004 10:50:26 -0700, be*****@peacefire.org (Bennett
Haselton) wrote:
I want to display a hierarchical listing of items from a database
table, where, say, each row in the table has an "ID" field and a
"parent_id" field giving the ID of its parent (NULL if it's at the top
level of the hierarchy) -- like message posts and their replies. Is
there a built-in way to do this, or a generally accepted simplest way?

My first idea was to create a user control like HierarchicalListing
that contains a Repeater, and the repeater's ItemTemplate would itself
contain an instance of HierarchicalListing. Then when putting the
HierarchicalListing on the page, you set its DataSource and have it
query for all rows where the parent_id is null, and databind the
Repeater to the results -- and then inside the Repeater, look at the
ID of the current row, and for the HierarchicalListing inside the
Repeater, have it query for all rows where the parent_id was equal to
that ID. That would give you a hierarchical listing of all the rows,
if ASP.Net allowed it.

Unfortunately if you try adding
<%@ Register TagPrefix="uc1" TagName="HierarchicalPostListing"
Src="HierarchicalPostListing.ascx" %>
to the top of HierarchicalPostListing.ascx itself, you get a run-time
error that circular file references are not allowed.

So, is there a way for a user control to be nested inside itself (or
rather, to be nested conditionally inside itself, so you don't get an
infinite recursion)? More importantly, is there a generally accepted
way to do a hierarchical listing like what I'm trying to do?

-Bennett


Nov 18 '05 #3
I thought I remembered something about a "TreeView" control and I tried
looking it up before coming up with my approach, but when I searched in
the MSDN index with the ".NET Framework" filter set, it only showed the
Windows Forms TreeView control. Then when I removed that filter, I did
find the Microsoft.Web.UI.WebControls.TreeView control.

However,
http://msdn.microsoft.com/library/de...p/webcontrols/
overview/overview.asp says that the controls in that namespace "deliver
content that renders in all commonly used browsers, while taking
advantage of powerful features supported by Internet Explorer 5.5 or
later versions". Now I'm really confused:

If they work in all browsers, then why do they get their own namespace,
where they're officially unsupported and Visual Studio .Net has no
built-in support for them?

And if they don't work in all browsers, then I can't use those anyway.

Anyway,
http://msdn.microsoft.com/library/de...p/webcontrols/
overview/overview.asp makes it look like the TreeView is for
hierarchical views that needs to be expandable and collapsable, which is
why it requires fancy tricks like client-side scripting and DHTML.
That's overkill for what I want to do; I just need a hierarchical view
that doesn't need to change.

-Bennett

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2030
by: Reimar Bauer | last post by:
Hi all, I would like to use a hierarchical group oriented encryption. Is there something implemented or did you know something I could use? For explanaition. If you have a large building...
1
3666
by: ALEX KLEIN | last post by:
I want to use fabricated hierarchical recordset in VB6 using ADO. I wrote code like dim rs as adodb.recordest set rs=new adodb.recordest rs.fields.append "a1",adChar,30 Then in loop I put...
2
3620
by: John | last post by:
Hi, We have XML files (and its XSD) that are dump of our tree-like data structure in memory. These XML files may potentially have unlimited levels of nesting because some elements can contain...
13
5852
by: Anton.Nikiforov | last post by:
Hello everybody! Does someone know how to build hierarchical queries to the postgresql? I have a table with tree in it (id, parent) and need to find a way from any point of the tree to any...
1
1785
by: jayson_13 | last post by:
Hi, I want to retrieve the hierarchical structure which is store inside the database and then display it using treeview control. But now I got a design issue which I hope that you guys can help...
5
2234
by: clintonG | last post by:
I'm looking for documentation and would not turn my nose up to any code from anybody who thinks they are good at the design of an algorythm that can be used to generated a hierarchical relational...
10
1734
by: Darian | last post by:
Is there a way to find all the thread names that are running in a project? For example, if I have 5 threads T1, T2, T3, T4, T5...and T2, T4, and T5 are running...I want to be able to know that...
2
3247
by: Juuso Hukkanen | last post by:
I need a list of multithreading unsafe C (C99) functions/features. comp.programming.threads provided an initial list of C:ish functions, with following ANSI C functions: asctime, gmtime,...
36
1880
by: Neil | last post by:
I received a message in another newsgroup saying that I shouldn't top-post my replies. I always top-post, because I feel it's easier for the reader to see the reply, rather than having to go to the...
0
7131
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5470
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4600
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.