Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Help with query - bulleted list?

Author  Topic 

the_b_man
Starting Member

1 Post

Posted - 2007-09-23 : 14:18:22
I have what I think is a unique problem.

I'm building an ASP.NET app with a GridView, basically giving a small bulleted list of related records, for each record in the main table. Here's a simplified version of what I'm trying to do...

ie. Final output:

---------------------------
Joe's Produce | * Apples
| * Bananas
| * Pears
---------------------------
Fresh Market | * Apples
| * Pears
---------------------------
City Orchard | * Apples
---------------------------


There's only a small number of possible products (about 8).
I'm using three tables, one for the companies, one for the products, and one to connect products to companies using companies and products FK's.

Companies
---------------
ID | autoincrement PK
Name | varchar
---------------

Products
---------------
ID | autoincrement PK
Name | varchar
---------------

OfferedProducts
---------------
Company | FK->Company.ID
Product | FK->Products.ID
---------------

It's the query I'm having trouble with. If I just do a SELECT with JOINs, I get a row for each product and this isn't the desired output (client wants a tiny bulleted list beside rows that alternate colour)

Is it possible to do an "inner" query for each row, and somehow have it returned as bullets? If I need to use a stored procedure, that's cool too, I just can't get my head around the correct way to approach this.

Thanks in advance for helping, especially since it's my first post here!

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-09-23 : 17:01:18
Get all the records and do the grouping at the front end.
HEre's a sample: http://aspalliance.com/723_Enhancing_the_DataGrid_with_Grouped_Rows_and_Subheadings.all

Actually if you google for "Datagrid + custom grouping" you can find more articles..

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-09-23 : 19:26:11
(note: moved to ASP.NET forum)

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -