DropDownList in DataGrid and SQL Query with Child Rows

  • Thread starter Thread starter John Bonds
  • Start date Start date
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
 
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
 
Back
Top