I have a DataView Webpart that displays a set of list items (articles). In each item(article) being displayed, I want to show a counter of items from another list that are linked to the unique ID of the first list. My second list consists of comments. Essentially I want to have a comment counter per article.
Thank you in advance for your answers
It's very easy in SharePoint 2010.
You have to create a number/integer type column (say CommentCounter ) in the list (say artiLeList ) where you want to keep your article. You mentioned that you have an unique id in your articleList. So, when you create an item in the CommentList, you have to increment the CommentCounter of the artilceList with filtering by this unique id. You can do it easily by a workflow.
More detail:
Create a column named CommentCounter in articleList.
Open SharePoint designer and create a list workflow.
Select commentList on which this workflow should be run.
Create a variable say currentCC and set value, currentCC = commentCounter[articleList:id==current:id]
add 1 with currentCC into a new variable say newCC.
update commentCounter with the newCC.(
you can now easily show this value in your DataView WebPart.
For More information, Please query again.
Thank You.