Filter second datatable

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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top