nested classes in .NET generics

J

Jeff

hi

..net 3.5


i'm developing website where people can post comment on articles, and also
post comment on other comments.. nested

All comments belonging to an article has a link to the article, So no matter
what level in the tree the comment is, it always knows what article it is
created for....

In my webpage I want to use an ObjectDataSource which can get the collection
of comments and fill the datacontrol with it... Not sure how to pass a tree
of objects to a ObjectDataSource???

also I'm looking into how to design such nested class. Is it so that I just
create class and then add a field to that class which can hold the levels
underneath it, like this:

public class Comment {
private int _id;
private string _body;
private string _postedby;
private int _article;
private List<Comment> _replies

//I left out constructors etc from this example
}

any suggestions?
 
B

bruce barker

the ObjectDataSource only supports tabular data, not hierarchical data.
the XmlDataSource and the SiteMapDataSource are the only builtin one
that support hierarchical data like your threads. if these don't fit
your needs, you need to write your own datasource. there is a sample on
codeplex.

you class design look ok, but I'd add a back pointer (Parent) and maybe
siblings support.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top