Recursive objects trouble displaying

Recursive objects trouble displaying

Old forum URL: forums.lhotka.net/forums/t/6426.aspx


gidzone posted on Saturday, February 14, 2009

Hello,

I am having trouble with a business object that contains itself. 

In my system a user can comment on a post as well as a comment on a comment.  The database stores all comments in the same table.  There is a ParentId column which points the the CommentId of the top most comment. In my business layer there is a CommentInfoList which is a property on the CommentInfo object.

My issues is with trying to display this data.  I would like to use a listview in order to display this information hierarchically, but I am not sure the best route to accomplish this.  If anyone can point me in the right direction it would be greatly appreciated.

thanks!

-sanjay

skagen00 replied on Sunday, February 15, 2009

I suspect you're talking about Web.

In our system we were using a tree view initially to display hierarchical data. To bind a CSLA datasource to a tree view, you'll need to look into IHierarchicalDataSource and accomodate that.

Chris

 

gidzone replied on Monday, February 16, 2009

Chris,

Thanks for the reply.  I am talking about web.  I wanted to use a ListView so I didn't have to worry about the IHierarchicalDataSource. 

I think that the only way for me to do this is to recursively loop through the object.

-sanjay

skagen00 replied on Monday, February 16, 2009

Another option is for you to compress your hierarchical data source into a single readonlylistbase or provide a property as a view of your hierarchical data model in code and bind to that.

In our case for hierarchical coding, a solution we eventually moved to involved a readonlylistbase of Code instances that had references to their parent in the list (NonSerialized to prevent remoting issues) and you could then fairly easily provide a FullCodeName property which might provide a Area / Category / SubCategory sort of expression that could be bound.

Obviously the sorting of this list is important - when we built the list of codes the algorithm was to end up with a list like this:

Area1

Area1 / Category1

Area1 / Category1 / SubCategory1

Area1 / Category2

Area1 / Category3

Area2 / Category4

etc.

Then, binding was pretty straightforward ... display value was the FullCodeName and the data value was the Id of the code.

Anyways, HTH

Chris

 

Copyright (c) Marimer LLC