Connecting Tech Pros Worldwide Forums | Help | Site Map

how to do a hierarchical listing of posting threads?

Bennett Haselton
Guest
 
Posts: n/a
#1: Nov 18 '05
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

CJ Taylor
Guest
 
Posts: n/a
#2: Nov 18 '05

re: how to do a hierarchical listing of posting threads?


Perhaps what your looking for is a TreeView..


"Bennett Haselton" <bennett@peacefire.org> wrote in message
news:e614455c.0409270950.7306ad5@posting.google.co m...[color=blue]
> 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[/color]


Scott Allen
Guest
 
Posts: n/a
#3: Nov 18 '05

re: how to do a hierarchical listing of posting threads?


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, bennett@peacefire.org (Bennett
Haselton) wrote:
[color=blue]
>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[/color]

Bennett Haselton
Guest
 
Posts: n/a
#4: Nov 18 '05

re: how to do a hierarchical listing of posting threads?


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!
Closed Thread