473,503 Members | 2,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DropDownList in DataGrid and SQL Query with Child Rows

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
Nov 17 '05 #1
2 1484
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

"John Bonds" <jo*******@hotmail.com> wrote in message
news:en**************@TK2MSFTNGP12.phx.gbl...
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

Nov 17 '05 #2
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

"John Bonds" <jo*******@hotmail.com> wrote in message
news:en**************@TK2MSFTNGP12.phx.gbl...
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

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
16975
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
0
296
by: John Bonds | last post by:
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...
1
1701
by: m3ckon | last post by:
Hi there, please help if you can, I'm having an issue with droponnlists in a datagrid I have a datagrid which is populated from a query .. all works fine I've added two extra columns, one...
4
2093
by: wolfgang wagner | last post by:
hi all! after successfully integrating a dropdownlist in my datagrid i have another problem: i cannot set the selected index of the dropdownlistbox. here is my code: hardware.aspx...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
7011
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4689
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
401
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.