DropDownList in DataGrid and SQL Query with Child Rows

J

John Bonds

I have made a Template column in my DataGrid that contains a DropDownList.
My main SQL query that is bound to this datagrid joins with another table in
the following way:

SELECT * FROM Customer
INNER JOIN Orders ON Orders.CustomerID = Customer.CustomerID

So I will get multiple rows returned for each customer per their orders.
I want to only show the customer once and have the DropDownList contain that
customer's orders. How do I do this?

Thanks,

John
 
M

Morten

You can user Group by.

This is from Northwind:
SELECT dbo.Customers.CustomerID, dbo.Customers.CompanyName,
dbo.Customers.ContactName, dbo.Customers.ContactTitle,
dbo.Customers.Address,
dbo.Customers.City, dbo.Customers.Region,
dbo.Customers.PostalCode, dbo.Customers.Country, dbo.Customers.Phone,
dbo.Customers.Fax
FROM dbo.Customers INNER JOIN
dbo_Orders ON dbo_Orders.CustomerID =
dbo.Customers.CustomerID
GROUP BY dbo.Customers.CustomerID, dbo.Customers.CompanyName,
dbo.Customers.ContactName, dbo.Customers.ContactTitle,
dbo.Customers.Address,
dbo.Customers.City, dbo.Customers.Region,
dbo.Customers.PostalCode, dbo.Customers.Country, dbo.Customers.Phone,
dbo.Customers.Fax

Morten
 

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

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,277
Latest member
VytoKetoReview

Latest Threads

Top