views:

73

answers:

2

I'm just wondering what's the best way to implement a threaded conversation like the Facebook Wall where the comments are displayed under each post, and older comments are collapsed and expandable. My instinct is to use a nested datalist, but I think that might take a toll on performance.

+1  A: 

I'd use 2 DataLists.

DataListA would only show the top 5 comments, but underneath DataListA would be a LinkButton with the text "### more comments...". (This LinkButton would be hidden when there are a total of 5 or fewer comments)

When the user clicks on the LinkButton, DataListA is hidden and DataListB is shown.

DataListB shows all comments, not just the first 5.

The LinkButton, of course, would have its text change to "hide ### comments..." when DataListB is showing.

If you cache your dataset in the ASP.NET Cache Object, then it won't be a performance hit.

hamlin11
+1  A: 

I would look into using ASP .NET MVC instead of webforms. I would load the first few posts server side with the initial page load and then look at implementing a client-side solution using AJAX with jQuery to retrieve additional records - there is an example of that here.

Nate Pinchot