473,385 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 1476
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
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
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
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
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.