Filter second datatable

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I want to display something like this in a Repeater:

Headline
Abstract
Date Posted

Filed under: Cat1 | Cat2 | Cat3
------------------------------------
Headline
Abstract
Date Posted

Filed under: Cat1 | Cat2 | Cat3
-------------------------------------

I have a proc which returns a dataset containing 2 datatables. The first
one contains the Article details (ID, Headline, etc) and the second one
contains all the categories. My table structure is like this:

tblArticles
ArticleID
Headline
Abstract
DatePosted

tblCategories
CatagoryID
Category

tblArticleCategories
ArticleID
CategoryID

I read an interesting article on nesting repeaters, but this is not quite
what I want, because I want the "Filed Under: Cat2 | Cat3" etc to appear on
one line. Can anyone give me any pointers as to what approach I should be
taking? I want to avoid making separate calls to the database for the
categories of each article within the Repeater's ItemDataBound event, unless
of course this is the best way...

Thanks
 
Hi Mike,
There are many ways of doing it without making calls to database again and
again.
1. Get all the three tables from the database in the dataset. In the
ItemBound event, you have the article id, you can get all the categories,
generate a concatenated string and display it in the repeater with the
article itself.
2. From the database populate an article table with an extra col Categories
which contains a - or | seperated categories. You can simply bind this table
to repeater.

I hope this helps.
 
Back
Top