View Single Post
  #7 (permalink)  
Old February 13th, 2009, 10:37 AM
philthy philthy is offline
Authorized User
Join Date: Mar 2007
Location: , , Denmark.
Posts: 52
Thanks: 6
Thanked 2 Times in 2 Posts

Originally Posted by Lee Dumond View Post
The way I did it was to use a nested ListView -- where the list of articles is a ListView, and the lists of tags is

also a ListView nested inside of the Articles list.

(Hint: You don't bind the inner ListView with an ObjectDataSource, only the outer one...)
Thats exactly how I did it, only difference is that I also bound the inner ListView to an ObjectDataSource. I have a class Tag, and this class has a method "GetTagsByArticle". So, I made that the select method, and then the Tag class as Type in this ObjectDataSource.

The problem I'm having is that the inner ListView doesn't seem to know which article ID to use. I have the DataKeyNames property set to "ID".

However, if I provide the Tag ObjectDataSource with a default value for the select parameter, it works (but only for that particular articleID).

I bind the outer ListView to an ObjectDataSource to get the articles, and the inner ListView to an ObjectDataSource to get the tags for each article.

So, the outer ListView uses GetArticles in the Article class to write the data for each entry in the articles list, and when it reaches the inner ListView, this uses the GetTagsByArticle(articleID) to write the tags for that particular article. I want the articleID for GetTagsByArticle to be that of the current article which is being written by the outer ListView, and this is where I'm stuck. It's like these two ListViews need to be syncronized somehow...

In my design, I decided to create a class for tags, like the ones for comments and categories. Therefore, it felt natural to have one ObjectDataSource for articles, and another one for tags, but since the tags are written in a nested ListView, apparently this is harder than I thought.
I have this many-to-many relationship between the articles and the tags, and it works fine.

I hope you understand the nonsense I'm writing, but hey, I'm Danish :-D

Again, thanks so much for all the help...