By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,853 Members | 2,186 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,853 IT Pros & Developers. It's quick & easy.

how to do a hierarchical listing of posting threads?

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.